Skip to content

Commit

Permalink
update pyproject.toml, ignore some ruff errors per-case
Browse files Browse the repository at this point in the history
  • Loading branch information
ilius committed Jan 5, 2025
1 parent 1ec1271 commit 1ce77f3
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 18 deletions.
2 changes: 1 addition & 1 deletion pyglossary/info_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def finish(self) -> None:
self._file.close()
self._file = nullTextIO

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

Expand Down
3 changes: 2 additions & 1 deletion pyglossary/plugins/appledict/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ def open(self, dirname: str) -> None:
if not isdir(dirname):
os.mkdir(dirname)

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

Expand Down
6 changes: 4 additions & 2 deletions pyglossary/plugins/appledict_bin/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ def fixLink(self, a: Element) -> Element:
return a

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

try:
Expand Down Expand Up @@ -499,7 +500,8 @@ def setKeyTextData(
)

# TODO: PLR0912 Too many branches (16 > 12)
def readKeyTextData( # noqa: PLR0912
# TODO: PLR0915 Too many statements (56 > 50)
def readKeyTextData( # noqa: PLR0912, PLR0915
self,
buff: io.BufferedIOBase,
bufferOffset: int,
Expand Down
6 changes: 4 additions & 2 deletions pyglossary/plugins/babylon_bgl/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -1265,7 +1265,8 @@ def processAlternativeKey(self, b_word: bytes, b_key: bytes) -> str:

# TODO: break it down
# PLR0912 Too many branches (20 > 12)
def processDefi(self, b_defi: bytes, b_key: bytes) -> str: # noqa: PLR0912
# PLR0915 Too many statements (60 > 50)
def processDefi(self, b_defi: bytes, b_key: bytes) -> str: # noqa: PLR0912, PLR0915
"""
b_defi: bytes
b_key: bytes.
Expand Down Expand Up @@ -1424,7 +1425,8 @@ def findDefiFieldsStart(self, b_defi: bytes) -> int:

# TODO: break it down
# PLR0912 Too many branches (41 > 12)
def collectDefiFields( # noqa: PLR0912
# PLR0915 Too many statements (121 > 50)
def collectDefiFields( # noqa: PLR0912, PLR0915
self,
b_defi: bytes,
b_key: bytes,
Expand Down
23 changes: 12 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ exclude = [

[tool.ruff.lint]
select = [
# "ANN", # flake8-annotationsq
"ANN", # flake8-annotationsq
"F", # Pyflakes
"E", # pycodestyle Error
"W", # pycodestyle Warning
Expand Down Expand Up @@ -93,37 +93,36 @@ select = [
"RUF", # Ruff-specific rules
]
ignore = [
"ANN003", # Missing type annotation for `**kwargs`, 15 remaining
"PLR0917", # Too many positional arguments (x/5)
"PLR0914", # Too many local variables (x/15)
"ANN401", # Dynamically typed expressions (typing.Any) are disallowed in ...
"ANN003", # Missing type annotation for `**kwargs`, 22 remaining

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

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

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

# Allow autofix for all enabled rules (when `--fix`) is provided.
Expand Down Expand Up @@ -203,19 +202,21 @@ mccabe.max-complexity = 13 # Unlike Flake8, default to a complexity level of 10.
]
"scripts/wiki-formats.py" = ["E501"]
"pyglossary/io_utils.py" = ["ANN"]
"pyglossary/plugins/babylon_bgl/bgl_reader_debug.py" = ["ANN", "FURB"]
"pyglossary/plugins/babylon_bgl/reader_debug.py" = ["ANN", "FURB"]
"pyglossary/ui/**/*.py" = [
"ANN",
"T201",
"PERF203",
"PLR0904", # Too many public methods
"PLR0912", # Too many branches
"PLR0915", # Too many statements
"PLR6301", # Method `...` could be a function, class method, or static method
"C90", # mccabe: C901: {name} is too complex ({complexity})
]
"tests/*.py" = [
"ANN",
"T201",
"PLR0915", # Too many statements
"PLR6301", # Method `...` could be a function, class method, or static method
"E501", # Line too long
]
Expand Down
2 changes: 1 addition & 1 deletion tests/g_dsl_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def test_headword_formatting_english(self):
self.convert_string_dsl_txt(dsl, txt)

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

0 comments on commit 1ce77f3

Please sign in to comment.