diff --git a/codespell_lib/_codespell.py b/codespell_lib/_codespell.py index dadb575378b..d3c180dbea7 100644 --- a/codespell_lib/_codespell.py +++ b/codespell_lib/_codespell.py @@ -26,7 +26,7 @@ from typing import Dict, List, Match, Optional, Pattern, Sequence, Set, Tuple # autogenerated by setuptools_scm -from ._version import __version__ as VERSION +from ._version import __version__ as VERSION # noqa: N812 word_regex_def = "[\\w\\-'’`]+" # While we want to treat characters like ( or " as okay for a starting break, @@ -228,7 +228,7 @@ def open_with_chardet(self, filename: str) -> Tuple[List[str], str]: break self.encdetector.close() encoding = self.encdetector.result["encoding"] - assert encoding is not None + assert encoding is not None # noqa: S101 try: f = open(filename, encoding=encoding, newline="") @@ -556,14 +556,14 @@ def parse_options( import tomllib # type: ignore[import] except ModuleNotFoundError: try: - import tomli as tomllib + import tomli as tomllib # type: ignore[no-redef] except ImportError as e: if tomllib_raise_error: raise ImportError( f"tomllib or tomli are required to read pyproject.toml " f"but could not be imported, got: {e}" ) from None - tomllib = None + tomllib = None # type: ignore[assignment] if tomllib is not None: for toml_file in toml_files: with open(toml_file, "rb") as f: diff --git a/pyproject.toml b/pyproject.toml index 99f14e77072..5944a2db79f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -103,14 +103,9 @@ addopts = "--cov=codespell_lib -rs --cov-report= --tb=short --junit-xml=junit-re [tool.ruff] extend-ignore = [ - "A003", "ANN101", - "ANN401", "B904", - "N802", - "N812", "PLW2901", - "S101", ] line-length = 88 select = [ @@ -137,6 +132,11 @@ target-version = "py37" [tool.ruff.mccabe] max-complexity = 45 +[tool.ruff.per-file-ignores] +"codespell_lib/_codespell.py" = ["A003"] +"codespell_lib/tests/test_*" = ["S101"] +"codespell_lib/tests/test_basic.py" = ["ANN401", "N802"] + [tool.ruff.pylint] allow-magic-value-types = ["bytes", "int", "str",] max-args = 12