Skip to content

Commit 6ed5df1

Browse files
Update ruff settings (codespell-project#3558)
1 parent 36a6871 commit 6ed5df1

File tree

4 files changed

+44
-37
lines changed

4 files changed

+44
-37
lines changed

codespell_lib/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
from ._codespell import _script_main, main
22
from ._version import __version__ # type: ignore[import-not-found]
33

4-
__all__ = ["_script_main", "main", "__version__"]
4+
__all__ = ["__version__", "_script_main", "main"]

codespell_lib/tests/test_basic.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -217,12 +217,12 @@ def test_permission_error(
217217
fname.write_text("abandonned\n")
218218
result = cs.main(fname, std=True)
219219
assert isinstance(result, tuple)
220-
code, _, stderr = result
220+
_, _, stderr = result
221221
assert "WARNING:" not in stderr
222222
fname.chmod(0o000)
223223
result = cs.main(fname, std=True)
224224
assert isinstance(result, tuple)
225-
code, _, stderr = result
225+
_, _, stderr = result
226226
assert "WARNING:" in stderr
227227

228228

@@ -464,7 +464,7 @@ def test_inline_ignores(
464464
expected_error_count: int,
465465
) -> None:
466466
d = str(tmpdir)
467-
with open(op.join(d, "bad.txt"), "w") as f:
467+
with open(op.join(d, "bad.txt"), "w", encoding="utf-8") as f:
468468
f.write(content)
469469
assert cs.main(d) == expected_error_count
470470

@@ -772,7 +772,7 @@ def _helper_test_case_handling_in_fixes(
772772
fname.write_text("early adoptor\n")
773773
result = cs.main("-D", dictionary_name, fname, std=True)
774774
assert isinstance(result, tuple)
775-
code, stdout, _ = result
775+
_, stdout, _ = result
776776
# all suggested fixes must be lowercase too
777777
assert "adopter, adaptor" in stdout
778778
# the reason, if any, must not be modified
@@ -783,7 +783,7 @@ def _helper_test_case_handling_in_fixes(
783783
fname.write_text("Early Adoptor\n")
784784
result = cs.main("-D", dictionary_name, fname, std=True)
785785
assert isinstance(result, tuple)
786-
code, stdout, _ = result
786+
_, stdout, _ = result
787787
# all suggested fixes must be capitalized too
788788
assert "Adopter, Adaptor" in stdout
789789
# the reason, if any, must not be modified
@@ -794,7 +794,7 @@ def _helper_test_case_handling_in_fixes(
794794
fname.write_text("EARLY ADOPTOR\n")
795795
result = cs.main("-D", dictionary_name, fname, std=True)
796796
assert isinstance(result, tuple)
797-
code, stdout, _ = result
797+
_, stdout, _ = result
798798
# all suggested fixes must be uppercase too
799799
assert "ADOPTER, ADAPTOR" in stdout
800800
# the reason, if any, must not be modified
@@ -805,7 +805,7 @@ def _helper_test_case_handling_in_fixes(
805805
fname.write_text("EaRlY AdOpToR\n")
806806
result = cs.main("-D", dictionary_name, fname, std=True)
807807
assert isinstance(result, tuple)
808-
code, stdout, _ = result
808+
_, stdout, _ = result
809809
# all suggested fixes should be lowercase
810810
assert "adopter, adaptor" in stdout
811811
# the reason, if any, must not be modified
@@ -1234,7 +1234,7 @@ def test_quiet_level_32(
12341234
d = tmp_path / "files"
12351235
d.mkdir()
12361236
conf = str(tmp_path / "setup.cfg")
1237-
with open(conf, "w") as f:
1237+
with open(conf, "w", encoding="utf-8") as f:
12381238
# It must contain a "codespell" section.
12391239
f.write("[codespell]\n")
12401240
args = ("--config", conf)
@@ -1263,7 +1263,7 @@ def test_ill_formed_ini_config_file(
12631263
d = tmp_path / "files"
12641264
d.mkdir()
12651265
conf = str(tmp_path / "setup.cfg")
1266-
with open(conf, "w") as f:
1266+
with open(conf, "w", encoding="utf-8") as f:
12671267
# It should contain but lacks a section.
12681268
f.write("foobar =\n")
12691269
args = ("--config", conf)

codespell_lib/tests/test_dictionary.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -315,11 +315,11 @@ def test_dictionary_looping(
315315
reps = [r for r in reps if len(r)]
316316
this_err_dict[err] = reps
317317
# 1. check the dict against itself (diagonal)
318-
for err in this_err_dict:
318+
for err, reps in this_err_dict.items():
319319
assert word_regex.fullmatch(
320320
err
321321
), f"error {err!r} does not match default word regex '{word_regex_def}'"
322-
for r in this_err_dict[err]:
322+
for r in reps:
323323
assert r not in this_err_dict, (
324324
f"error {err}: correction {r} is an error itself "
325325
f"in the same dictionary file {short_fname}"
@@ -337,12 +337,12 @@ def test_dictionary_looping(
337337
# 2. check corrections in this dict against other dicts (upper)
338338
pair = (short_fname, other_fname)
339339
if pair not in allowed_dups:
340-
for err in this_err_dict:
340+
for err, reps in this_err_dict.items():
341341
assert err not in other_err_dict, (
342342
f"error {err!r} in dictionary {short_fname} "
343343
f"already exists in dictionary {other_fname}"
344344
)
345-
for r in this_err_dict[err]:
345+
for r in reps:
346346
assert r not in other_err_dict, (
347347
f"error {err}: correction {r} from dictionary {short_fname} "
348348
f"is an error itself in dictionary {other_fname}"

pyproject.toml

+30-23
Original file line numberDiff line numberDiff line change
@@ -109,29 +109,6 @@ filterwarnings = ["error"]
109109
line-length = 88
110110

111111
[tool.ruff.lint]
112-
ignore = [
113-
"ANN101",
114-
"B904",
115-
"PLW2901",
116-
"RET505",
117-
"SIM105",
118-
"SIM115",
119-
# https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules
120-
"W191",
121-
"E111",
122-
"E114",
123-
"E117",
124-
"D206",
125-
"D300",
126-
"Q000",
127-
"Q001",
128-
"Q002",
129-
"Q003",
130-
"COM812",
131-
"COM819",
132-
"ISC001",
133-
"ISC002",
134-
]
135112
select = [
136113
"A",
137114
"ANN",
@@ -157,6 +134,36 @@ select = [
157134
"W",
158135
"YTT",
159136
]
137+
ignore = [
138+
"ANN101",
139+
"B904",
140+
"PLR0914",
141+
"PLR6201",
142+
"PLW2901",
143+
"PT004", # deprecated
144+
"PT005", # deprecated
145+
"RET505",
146+
"S404",
147+
"SIM105",
148+
"SIM115",
149+
"UP027", # deprecated
150+
"UP038", # https://github.com/astral-sh/ruff/issues/7871
151+
# https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules
152+
"W191",
153+
"E111",
154+
"E114",
155+
"E117",
156+
"D206",
157+
"D300",
158+
"Q000",
159+
"Q001",
160+
"Q002",
161+
"Q003",
162+
"COM812",
163+
"COM819",
164+
"ISC001",
165+
"ISC002",
166+
]
160167

161168
[tool.ruff.lint.mccabe]
162169
max-complexity = 45

0 commit comments

Comments
 (0)