Skip to content

Commit

Permalink
ruff: Use format specifiers instead of percent format (#2787)
Browse files Browse the repository at this point in the history
  • Loading branch information
cclauss authored Mar 12, 2023
1 parent 6774b1a commit 64459cc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
4 changes: 2 additions & 2 deletions codespell_lib/_codespell.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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="")
Expand Down
8 changes: 4 additions & 4 deletions codespell_lib/tests/test_dictionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
if os.getenv("REQUIRE_ASPELL", "false").lower() == "true":
raise RuntimeError(
"Cannot run complete tests without aspell when "
"REQUIRE_ASPELL=true. Got error during import:\n%s" % (exp,)
"REQUIRE_ASPELL=true. Got error during import:\n{}".format(exp)
)
else:
warnings.warn(
"aspell not found, but not required, skipping aspell tests. Got "
"error during import:\n%s" % (exp,)
"error during import:\n{}".format(exp)
)

global_err_dicts: Dict[str, Dict[str, Any]] = {}
Expand Down Expand Up @@ -289,8 +289,8 @@ def test_dictionary_looping(
for err in this_err_dict:
for r in this_err_dict[err]:
assert r not in this_err_dict, (
"error %s: correction %s is an error itself in the same "
"dictionary file %s" % (err, r, short_fname)
"error {}: correction {} is an error itself in the same "
"dictionary file {}".format(err, r, short_fname)
)
pair = (short_fname, short_fname)
assert pair not in global_pairs
Expand Down
11 changes: 5 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -103,15 +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",
"UP031",
]
line-length = 88
select = [
Expand All @@ -138,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
Expand Down

0 comments on commit 64459cc

Please sign in to comment.