Skip to content

Commit 654b3ed

Browse files
Run ruff format
1 parent 913871e commit 654b3ed

File tree

3 files changed

+20
-24
lines changed

3 files changed

+20
-24
lines changed

codespell_lib/_codespell.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@
5858
# these may occur unescaped in URIs, and so we are more restrictive on the
5959
# endpoint. Emails are more restrictive, so the endpoint remains flexible.
6060
uri_regex_def = (
61-
"(\\b(?:https?|[ts]?ftp|file|git|smb)://[^\\s]+(?=$|\\s)|"
62-
"\\b[\\w.%+-]+@[\\w.-]+\\b)"
61+
"(\\b(?:https?|[ts]?ftp|file|git|smb)://[^\\s]+(?=$|\\s)|\\b[\\w.%+-]+@[\\w.-]+\\b)"
6362
)
6463
inline_ignore_regex = re.compile(r"[^\w\s]\s?codespell:ignore\b(\s+(?P<words>[\w,]*))?")
6564
USAGE = """
@@ -763,9 +762,9 @@ def ask_for_word_fix(
763762
return misspelling.fix, fix_case(wrongword, misspelling.data)
764763

765764
line_ui = (
766-
f"{line[:match.start()]}"
765+
f"{line[: match.start()]}"
767766
f"{colors.WWORD}{wrongword}{colors.DISABLE}"
768-
f"{line[match.end():]}"
767+
f"{line[match.end() :]}"
769768
)
770769

771770
if misspelling.fix and interactivity & 1:
@@ -1057,8 +1056,7 @@ def parse_file(
10571056
print_context(lines, i, context)
10581057
if filename != "-":
10591058
print(
1060-
f"{cfilename}:{cline}: {cwrongword} "
1061-
f"==> {crightword}{creason}"
1059+
f"{cfilename}:{cline}: {cwrongword} ==> {crightword}{creason}"
10621060
)
10631061
elif options.stdin_single_line:
10641062
print(f"{cline}: {cwrongword} ==> {crightword}{creason}")

codespell_lib/tests/test_basic.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -368,9 +368,7 @@ def test_ignore_words_with_cases(
368368
"""Test case-sensitivity implemented for -I and -L options in #3272."""
369369
bad_name = tmp_path / "MIS.txt"
370370
bad_name.write_text(
371-
"1 MIS (Management Information System) 1\n"
372-
"2 Les Mis (1980 musical) 2\n"
373-
"3 mis 3\n"
371+
"1 MIS (Management Information System) 1\n2 Les Mis (1980 musical) 2\n3 mis 3\n"
374372
)
375373
assert cs.main(bad_name) == 3
376374
assert cs.main(bad_name, "-f") == 4

codespell_lib/tests/test_dictionary.py

+15-15
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,9 @@ def _check_err_rep(
144144
assert whitespace.search(err) is None, f"error {err!r} has whitespace"
145145
assert "," not in err, f"error {err!r} has a comma"
146146
assert len(rep) > 0, f"error {err}: correction {rep!r} must be non-empty"
147-
assert not start_whitespace.match(
148-
rep
149-
), f"error {err}: correction {rep!r} cannot start with whitespace"
147+
assert not start_whitespace.match(rep), (
148+
f"error {err}: correction {rep!r} cannot start with whitespace"
149+
)
150150
_check_aspell(err, f"error {err!r}", in_aspell[0], fname, languages[0])
151151
prefix = f"error {err}: correction {rep!r}"
152152
for regex, msg in (
@@ -166,9 +166,9 @@ def _check_err_rep(
166166
assert not regex.search(rep), msg % (prefix,)
167167
del msg
168168
if rep.count(","):
169-
assert rep.endswith(
170-
","
171-
), f'error {err}: multiple corrections must end with trailing ","'
169+
assert rep.endswith(","), (
170+
f'error {err}: multiple corrections must end with trailing ","'
171+
)
172172
reps = [r.strip() for r in rep.split(",")]
173173
reps = [r for r in reps if len(r)]
174174
for r in reps:
@@ -185,9 +185,9 @@ def _check_err_rep(
185185
# we could ignore the case, but that would miss things like days of the
186186
# week which we want to be correct
187187
reps = [r.lower() for r in reps]
188-
assert len(set(reps)) == len(
189-
reps
190-
), f'error {err}: corrections "{rep}" are not (lower-case) unique'
188+
assert len(set(reps)) == len(reps), (
189+
f'error {err}: corrections "{rep}" are not (lower-case) unique'
190+
)
191191

192192

193193
@pytest.mark.parametrize(
@@ -307,18 +307,18 @@ def test_dictionary_looping(
307307
for line in fid:
308308
err, rep = line.split("->")
309309
err = err.lower()
310-
assert (
311-
err not in this_err_dict
312-
), f"error {err!r} already exists in {short_fname}"
310+
assert err not in this_err_dict, (
311+
f"error {err!r} already exists in {short_fname}"
312+
)
313313
rep = rep.rstrip("\n")
314314
reps = [r.strip() for r in rep.lower().split(",")]
315315
reps = [r for r in reps if len(r)]
316316
this_err_dict[err] = reps
317317
# 1. check the dict against itself (diagonal)
318318
for err, reps in this_err_dict.items():
319-
assert word_regex.fullmatch(
320-
err
321-
), f"error {err!r} does not match default word regex '{word_regex_def}'"
319+
assert word_regex.fullmatch(err), (
320+
f"error {err!r} does not match default word regex '{word_regex_def}'"
321+
)
322322
for r in reps:
323323
assert r not in this_err_dict, (
324324
f"error {err}: correction {r} is an error itself "

0 commit comments

Comments
 (0)