diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4b9370e4..1b293c9b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 @@ -50,7 +50,7 @@ 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: @@ -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.11.8 hooks: - id: ruff - id: ruff-format @@ -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"] diff --git a/codetypo/_codetypo.py b/codetypo/_codetypo.py index e6383f22..029fa04a 100644 --- a/codetypo/_codetypo.py +++ b/codetypo/_codetypo.py @@ -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[\w,]*))?") USAGE = """ @@ -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: @@ -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}") diff --git a/codetypo/tests/test_basic.py b/codetypo/tests/test_basic.py index e8cecb84..a8ff95ce 100644 --- a/codetypo/tests/test_basic.py +++ b/codetypo/tests/test_basic.py @@ -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 diff --git a/codetypo/tests/test_dictionary.py b/codetypo/tests/test_dictionary.py index af979cd3..a79a8488 100644 --- a/codetypo/tests/test_dictionary.py +++ b/codetypo/tests/test_dictionary.py @@ -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 ( @@ -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: @@ -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( @@ -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 "