Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exclude: ^(\.[^/]*cache/.*)$
repos:
- repo: https://github.com/executablebooks/mdformat
# Do this before other tools "fixing" the line endings
rev: 0.7.21
rev: 0.7.22
hooks:
- id: mdformat
name: Format Markdown
Expand Down Expand Up @@ -50,15 +50,15 @@ repos:
files: dictionary.*\.txt$|\.wordlist$
args: [--ignore-case]
- repo: https://github.com/adrienverge/yamllint.git
rev: v1.35.1
rev: v1.37.1
hooks:
- id: yamllint
args:
- --no-warnings
- -d
- "{extends: relaxed, rules: {line-length: {max: 90}}}"
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.6
rev: v0.11.8
hooks:
- id: ruff
- id: ruff-format
Expand All @@ -68,11 +68,11 @@ repos:
- id: prettier
types_or: [yaml, markdown, html, css, scss, javascript, json]
- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.23
rev: v0.24.1
hooks:
- id: validate-pyproject
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.14.1
rev: v1.15.0
hooks:
- id: mypy
args: ["--config-file", "pyproject.toml"]
Expand Down
10 changes: 4 additions & 6 deletions codetypo/_codetypo.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@
# these may occur unescaped in URIs, and so we are more restrictive on the
# endpoint. Emails are more restrictive, so the endpoint remains flexible.
uri_regex_def = (
"(\\b(?:https?|[ts]?ftp|file|git|smb)://[^\\s]+(?=$|\\s)|"
"\\b[\\w.%+-]+@[\\w.-]+\\b)"
"(\\b(?:https?|[ts]?ftp|file|git|smb)://[^\\s]+(?=$|\\s)|\\b[\\w.%+-]+@[\\w.-]+\\b)"
)
inline_ignore_regex = re.compile(r"[^\w\s]\s?codetypo:ignore\b(\s+(?P<words>[\w,]*))?")
USAGE = """
Expand Down Expand Up @@ -763,9 +762,9 @@ def ask_for_word_fix(
return misspelling.fix, fix_case(wrongword, misspelling.data)

line_ui = (
f"{line[:match.start()]}"
f"{line[: match.start()]}"
f"{colors.WWORD}{wrongword}{colors.DISABLE}"
f"{line[match.end():]}"
f"{line[match.end() :]}"
)

if misspelling.fix and interactivity & 1:
Expand Down Expand Up @@ -1057,8 +1056,7 @@ def parse_file(
print_context(lines, i, context)
if filename != "-":
print(
f"{cfilename}:{cline}: {cwrongword} "
f"==> {crightword}{creason}"
f"{cfilename}:{cline}: {cwrongword} ==> {crightword}{creason}"
)
elif options.stdin_single_line:
print(f"{cline}: {cwrongword} ==> {crightword}{creason}")
Expand Down
4 changes: 1 addition & 3 deletions codetypo/tests/test_basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,9 +368,7 @@ def test_ignore_words_with_cases(
"""Test case-sensitivity implemented for -I and -L options in #3272."""
bad_name = tmp_path / "MIS.txt"
bad_name.write_text(
"1 MIS (Management Information System) 1\n"
"2 Les Mis (1980 musical) 2\n"
"3 mis 3\n"
"1 MIS (Management Information System) 1\n2 Les Mis (1980 musical) 2\n3 mis 3\n"
)
assert cs.main(bad_name) == 3
assert cs.main(bad_name, "-f") == 4
Expand Down
30 changes: 15 additions & 15 deletions codetypo/tests/test_dictionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ def _check_err_rep(
assert whitespace.search(err) is None, f"error {err!r} has whitespace"
assert "," not in err, f"error {err!r} has a comma"
assert len(rep) > 0, f"error {err}: correction {rep!r} must be non-empty"
assert not start_whitespace.match(
rep
), f"error {err}: correction {rep!r} cannot start with whitespace"
assert not start_whitespace.match(rep), (
f"error {err}: correction {rep!r} cannot start with whitespace"
)
_check_aspell(err, f"error {err!r}", in_aspell[0], fname, languages[0])
prefix = f"error {err}: correction {rep!r}"
for regex, msg in (
Expand All @@ -166,9 +166,9 @@ def _check_err_rep(
assert not regex.search(rep), msg % (prefix,)
del msg
if rep.count(","):
assert rep.endswith(
","
), f'error {err}: multiple corrections must end with trailing ","'
assert rep.endswith(","), (
f'error {err}: multiple corrections must end with trailing ","'
)
reps = [r.strip() for r in rep.split(",")]
reps = [r for r in reps if len(r)]
for r in reps:
Expand All @@ -185,9 +185,9 @@ def _check_err_rep(
# we could ignore the case, but that would miss things like days of the
# week which we want to be correct
reps = [r.lower() for r in reps]
assert len(set(reps)) == len(
reps
), f'error {err}: corrections "{rep}" are not (lower-case) unique'
assert len(set(reps)) == len(reps), (
f'error {err}: corrections "{rep}" are not (lower-case) unique'
)


@pytest.mark.parametrize(
Expand Down Expand Up @@ -307,18 +307,18 @@ def test_dictionary_looping(
for line in fid:
err, rep = line.split("->")
err = err.lower()
assert (
err not in this_err_dict
), f"error {err!r} already exists in {short_fname}"
assert err not in this_err_dict, (
f"error {err!r} already exists in {short_fname}"
)
rep = rep.rstrip("\n")
reps = [r.strip() for r in rep.lower().split(",")]
reps = [r for r in reps if len(r)]
this_err_dict[err] = reps
# 1. check the dict against itself (diagonal)
for err, reps in this_err_dict.items():
assert word_regex.fullmatch(
err
), f"error {err!r} does not match default word regex '{word_regex_def}'"
assert word_regex.fullmatch(err), (
f"error {err!r} does not match default word regex '{word_regex_def}'"
)
for r in reps:
assert r not in this_err_dict, (
f"error {err}: correction {r} is an error itself "
Expand Down