Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pre-commit.ci] pre-commit autoupdate #27

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
6 changes: 3 additions & 3 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 @@ -58,7 +58,7 @@ repos:
- -d
- "{extends: relaxed, rules: {line-length: {max: 90}}}"
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.8.6
rev: v0.9.6
hooks:
- id: ruff
- id: ruff-format
Expand All @@ -72,7 +72,7 @@ repos:
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 @@ -47,7 +47,7 @@
for d in _builtin_dictionaries
]
fname_params = pytest.mark.parametrize(
"fname, in_aspell, in_dictionary", _fnames_in_aspell

Check failure on line 50 in codetypo/tests/test_dictionary.py

View workflow job for this annotation

GitHub Actions / 3.8

Ruff (PT006)

codetypo/tests/test_dictionary.py:50:5: PT006 Wrong type passed to first argument of `pytest.mark.parametrize`; expected `tuple`

Check failure on line 50 in codetypo/tests/test_dictionary.py

View workflow job for this annotation

GitHub Actions / 3.9

Ruff (PT006)

codetypo/tests/test_dictionary.py:50:5: PT006 Wrong type passed to first argument of `pytest.mark.parametrize`; expected `tuple`

Check failure on line 50 in codetypo/tests/test_dictionary.py

View workflow job for this annotation

GitHub Actions / 3.8

Ruff (PT006)

codetypo/tests/test_dictionary.py:50:5: PT006 Wrong type passed to first argument of `pytest.mark.parametrize`; expected `tuple`

Check failure on line 50 in codetypo/tests/test_dictionary.py

View workflow job for this annotation

GitHub Actions / 3.10

Ruff (PT006)

codetypo/tests/test_dictionary.py:50:5: PT006 Wrong type passed to first argument of `pytest.mark.parametrize`; expected `tuple`

Check failure on line 50 in codetypo/tests/test_dictionary.py

View workflow job for this annotation

GitHub Actions / 3.9

Ruff (PT006)

codetypo/tests/test_dictionary.py:50:5: PT006 Wrong type passed to first argument of `pytest.mark.parametrize`; expected `tuple`

Check failure on line 50 in codetypo/tests/test_dictionary.py

View workflow job for this annotation

GitHub Actions / 3.10

Ruff (PT006)

codetypo/tests/test_dictionary.py:50:5: PT006 Wrong type passed to first argument of `pytest.mark.parametrize`; expected `tuple`

Check failure on line 50 in codetypo/tests/test_dictionary.py

View workflow job for this annotation

GitHub Actions / 3.11

Ruff (PT006)

codetypo/tests/test_dictionary.py:50:5: PT006 Wrong type passed to first argument of `pytest.mark.parametrize`; expected `tuple`

Check failure on line 50 in codetypo/tests/test_dictionary.py

View workflow job for this annotation

GitHub Actions / 3.12

Ruff (PT006)

codetypo/tests/test_dictionary.py:50:5: PT006 Wrong type passed to first argument of `pytest.mark.parametrize`; expected `tuple`

Check failure on line 50 in codetypo/tests/test_dictionary.py

View workflow job for this annotation

GitHub Actions / 3.12

Ruff (PT006)

codetypo/tests/test_dictionary.py:50:5: PT006 Wrong type passed to first argument of `pytest.mark.parametrize`; expected `tuple`

Check failure on line 50 in codetypo/tests/test_dictionary.py

View workflow job for this annotation

GitHub Actions / 3.13

Ruff (PT006)

codetypo/tests/test_dictionary.py:50:5: PT006 Wrong type passed to first argument of `pytest.mark.parametrize`; expected `tuple`

Check failure on line 50 in codetypo/tests/test_dictionary.py

View workflow job for this annotation

GitHub Actions / 3.13

Ruff (PT006)

codetypo/tests/test_dictionary.py:50:5: PT006 Wrong type passed to first argument of `pytest.mark.parametrize`; expected `tuple`

Check failure on line 50 in codetypo/tests/test_dictionary.py

View workflow job for this annotation

GitHub Actions / 3.10 no-toml

Ruff (PT006)

codetypo/tests/test_dictionary.py:50:5: PT006 Wrong type passed to first argument of `pytest.mark.parametrize`; expected `tuple`

Check failure on line 50 in codetypo/tests/test_dictionary.py

View workflow job for this annotation

GitHub Actions / 3.10 no-toml

Ruff (PT006)

codetypo/tests/test_dictionary.py:50:5: PT006 Wrong type passed to first argument of `pytest.mark.parametrize`; expected `tuple`
)


Expand Down Expand Up @@ -144,9 +144,9 @@
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 @@
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 @@
# 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 @@
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
Loading