Skip to content

Commit 1ce77f3

Browse files
committed
update pyproject.toml, ignore some ruff errors per-case
1 parent 1ec1271 commit 1ce77f3

File tree

6 files changed

+24
-18
lines changed

6 files changed

+24
-18
lines changed

pyglossary/info_writer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def finish(self) -> None:
3535
self._file.close()
3636
self._file = nullTextIO
3737

38-
def write(self) -> Generator[None, EntryType, None]: # noqa: PLR0912, C901
38+
def write(self) -> Generator[None, EntryType, None]: # noqa: PLR0912, PLR0915, C901
3939
import re
4040
from collections import Counter
4141

pyglossary/plugins/appledict/writer.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ def open(self, dirname: str) -> None:
194194
if not isdir(dirname):
195195
os.mkdir(dirname)
196196

197-
def write(self) -> Generator[None, EntryType, None]: # noqa: PLR0912
197+
# TODO: PLR0915 Too many statements (74 > 50)
198+
def write(self) -> Generator[None, EntryType, None]: # noqa: PLR0912, PLR0915
198199
global BeautifulSoup
199200
from pyglossary.xdxf.transform import XdxfTransformer
200201

pyglossary/plugins/appledict_bin/reader.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ def fixLink(self, a: Element) -> Element:
135135
return a
136136

137137
# TODO: PLR0912 Too many branches (17 > 12)
138-
def open(self, filename: str) -> Iterator[tuple[int, int]]: # noqa: PLR0912
138+
# TODO: PLR0915 Too many statements (60 > 50)
139+
def open(self, filename: str) -> Iterator[tuple[int, int]]: # noqa: PLR0912, PLR0915
139140
from os.path import dirname
140141

141142
try:
@@ -499,7 +500,8 @@ def setKeyTextData(
499500
)
500501

501502
# TODO: PLR0912 Too many branches (16 > 12)
502-
def readKeyTextData( # noqa: PLR0912
503+
# TODO: PLR0915 Too many statements (56 > 50)
504+
def readKeyTextData( # noqa: PLR0912, PLR0915
503505
self,
504506
buff: io.BufferedIOBase,
505507
bufferOffset: int,

pyglossary/plugins/babylon_bgl/reader.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,7 +1265,8 @@ def processAlternativeKey(self, b_word: bytes, b_key: bytes) -> str:
12651265

12661266
# TODO: break it down
12671267
# PLR0912 Too many branches (20 > 12)
1268-
def processDefi(self, b_defi: bytes, b_key: bytes) -> str: # noqa: PLR0912
1268+
# PLR0915 Too many statements (60 > 50)
1269+
def processDefi(self, b_defi: bytes, b_key: bytes) -> str: # noqa: PLR0912, PLR0915
12691270
"""
12701271
b_defi: bytes
12711272
b_key: bytes.
@@ -1424,7 +1425,8 @@ def findDefiFieldsStart(self, b_defi: bytes) -> int:
14241425

14251426
# TODO: break it down
14261427
# PLR0912 Too many branches (41 > 12)
1427-
def collectDefiFields( # noqa: PLR0912
1428+
# PLR0915 Too many statements (121 > 50)
1429+
def collectDefiFields( # noqa: PLR0912, PLR0915
14281430
self,
14291431
b_defi: bytes,
14301432
b_key: bytes,

pyproject.toml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ exclude = [
3939

4040
[tool.ruff.lint]
4141
select = [
42-
# "ANN", # flake8-annotationsq
42+
"ANN", # flake8-annotationsq
4343
"F", # Pyflakes
4444
"E", # pycodestyle Error
4545
"W", # pycodestyle Warning
@@ -93,37 +93,36 @@ select = [
9393
"RUF", # Ruff-specific rules
9494
]
9595
ignore = [
96+
"ANN003", # Missing type annotation for `**kwargs`, 15 remaining
97+
"PLR0917", # Too many positional arguments (x/5)
98+
"PLR0914", # Too many local variables (x/15)
9699
"ANN401", # Dynamically typed expressions (typing.Any) are disallowed in ...
97-
"ANN003", # Missing type annotation for `**kwargs`, 22 remaining
98100

99101
"PYI042", # Type alias `...` should be CamelCase FIXME
100102
"RUF039", # First argument to `re.compile()` is not raw string
101103
"FURB189",
102104
# FURB189 Subclassing `dict` can be error prone, use `collections.UserDict` instead
103105
# FURB189 Subclassing `str` can be error prone, use `collections.UserStr` instead
104-
"COM812",
105-
"ISC001",
106+
"COM812", # Trailing comma missing
106107
"SLF", # Private member accessed
107108
"PYI034", # py3.11: `__iadd__` methods in classes like `SqEntryList` usually return `self` at runtime
108109
"DTZ001", # The use of `datetime.datetime()` without `tzinfo` argument is not allowed
109110
"DTZ005", # The use of `datetime.datetime.now()` without `tz` argument is not allowed
110111
"PGH003", # Use specific rule codes when ignoring type issues
111112

112-
"PLR0914", # Too many local variables, 17 cases, --preview
113-
"PLR0917", # Too many positional arguments, 23 cases, --preview
114-
"PLR0915", # Too many statements, 28 cases
113+
"PLR0915", # Too many statements
114+
"PLR0911", # Too many return statements (x > 6)
115+
"PLR2004", # Magic value used in comparison, consider replacing `...` with a constant variable
115116

116117
"FURB166", # Use of `int` with explicit `base=16` after removing prefix
117118
"FURB103", # `open` and `write` should be replaced by `Path(...
118-
"PLR2004", # Magic value used in comparison, consider replacing `...` with a constant variable
119119
"PLC0415", # `import` should be at the top-level of a file
120120
"PLW0603", # Using the global statement to update `mockLog` is discouraged
121121
"PT027", # Use `pytest.raises` instead of unittest-style `assertRaises`, why?
122122
"PD011", # Use `.to_numpy()` instead of `.values`, WTF?
123123
"ICN001", # `tkinter` should be imported as `tk`, WTF?
124124
"RUF005", # Consider `[*_list, x]` instead of concatenation
125125
"PT009", # Use a regular `assert` instead of unittest-style `assertEqual`, why?
126-
"PLR0911", # Too many return statements (x > 6)
127126
"RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`
128127
"BLE001", # Do not catch blind exception: `Exception`
129128
"G004", # Logging statement uses f-string, WTF?
@@ -151,8 +150,8 @@ ignore = [
151150
"SIM117", # Use a single with statement with multiple contexts...
152151
"UP009", # UTF-8 encoding declaration is unnecessary
153152
"UP037", # Remove quotes from type annotation
154-
"W191", # Indentation contains tabs
155153
"SIM115", # Use context handler for opening files
154+
"W191", # Indentation contains tabs
156155
]
157156

158157
# Allow autofix for all enabled rules (when `--fix`) is provided.
@@ -203,19 +202,21 @@ mccabe.max-complexity = 13 # Unlike Flake8, default to a complexity level of 10.
203202
]
204203
"scripts/wiki-formats.py" = ["E501"]
205204
"pyglossary/io_utils.py" = ["ANN"]
206-
"pyglossary/plugins/babylon_bgl/bgl_reader_debug.py" = ["ANN", "FURB"]
205+
"pyglossary/plugins/babylon_bgl/reader_debug.py" = ["ANN", "FURB"]
207206
"pyglossary/ui/**/*.py" = [
208207
"ANN",
209208
"T201",
210209
"PERF203",
211210
"PLR0904", # Too many public methods
212211
"PLR0912", # Too many branches
212+
"PLR0915", # Too many statements
213213
"PLR6301", # Method `...` could be a function, class method, or static method
214214
"C90", # mccabe: C901: {name} is too complex ({complexity})
215215
]
216216
"tests/*.py" = [
217217
"ANN",
218218
"T201",
219+
"PLR0915", # Too many statements
219220
"PLR6301", # Method `...` could be a function, class method, or static method
220221
"E501", # Line too long
221222
]

tests/g_dsl_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ def test_headword_formatting_english(self):
164164
self.convert_string_dsl_txt(dsl, txt)
165165

166166
def test_p_unclosed(self):
167-
dsl = "headword\n" " [m1][p]test\n"
167+
dsl = "headword\n [m1][p]test\n"
168168
txt = (
169169
"headword\t"
170170
'<p style="padding-left:1em;margin:0"><i class="p"><font color="green">test\\n</font></i>'

0 commit comments

Comments
 (0)