Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

flake8 pre-commit config incompatible with 3.12 #1670

Closed
@EliahKagan

Description

@EliahKagan

The configuration forflake8 in.pre-commit-config.yaml--specifically that version 6.0.0 is used--is incompatible with Python 3.12, producing an incorrect "E231 missing whitespace after ':'" error:

(.venv) ek@Glub:~/repos-wsl/GitPython (scripts)$ pre-commit run --all-filesflake8...................................................................Failed- hook id: flake8- exit code: 1git/cmd.py:479:34: E231 missing whitespace after ':'                f"The `{protocol}::` protocol looks suspicious, use `allow_unsafe_protocols=True` to allow it."                                 ^git/cmd.py:479:35: E231 missing whitespace after ':'                f"The `{protocol}::` protocol looks suspicious, use `allow_unsafe_protocols=True` to allow it."                                  ^git/refs/log.py:247:67: E226 missing whitespace around arithmetic operator                    raise IndexError(f"Index file ended at line {i+1}, before given index was reached")                                                                  ^1     E226 missing whitespace around arithmetic operator2     E231 missing whitespace after ':'3check for merge conflicts................................................Passedcheck toml...............................................................Passedcheck yaml...............................................................Passed

It also reports E226, which also happens only on Python 3.12, but appears intentional. But that's easy to fix (the simplest way being to add the spaces it wants, which also more resembles the overall style for the+ operator in this project).

The wrong: error (false positive E231) happens becauseflake8 6.0.0 depends onpycodestyle 2.10.*, which implements that check (E231) and has a parsing bug specific to Python 3.12. This was fixed inPyCQA/pycodestyle#1148.

Upgrading toflake8 6.1.0 gets the fix, since that version offlake8, currently the latest,depends onpycodestyle 2.11.*,which has it:

(.venv) ek@Glub:~/repos-wsl/GitPython (scripts)$ pre-commit autoupdate[https://github.com/PyCQA/flake8] updating 6.0.0 -> 6.1.0[https://github.com/pre-commit/pre-commit-hooks] already up to date!(.venv) ek@Glub:~/repos-wsl/GitPython (scripts *)$ pre-commit run --all-files[INFO] Installing environment for https://github.com/PyCQA/flake8.[INFO] Once installed this environment will be reused.[INFO] This may take a few minutes...flake8...................................................................Failed- hook id: flake8- exit code: 1git/objects/submodule/base.py:1406:16: E721 do not compare types, for exact checks use `is` / `is not`, for instance checks use `isinstance()`            if type(sm) != git.objects.submodule.base.Submodule:               ^git/refs/log.py:247:67: E226 missing whitespace around arithmetic operator                    raise IndexError(f"Index file ended at line {i+1}, before given index was reached")                                                                  ^git/util.py:1139:16: E721 do not compare types, for exact checks use `is` / `is not`, for instance checks use `isinstance()`            if type(base) == IterableClassWatcher:               ^1     E226 missing whitespace around arithmetic operator2     E721 do not compare types, for exact checks use `is` / `is not`, for instance checks use `isinstance()`3check for merge conflicts................................................Passedcheck toml...............................................................Passedcheck yaml...............................................................Passed

However, that reports E721 about the use of== to compare to atype object. So I think it makes sense for a fix for this to be part of a larger change that also fixes the new problems found byflake8, also bumps versions on the listedflake8 plugins (other than the default ones likepycodestyle) and fixes new warnings from that, and possibly addresses other style issues and/or expands the scope offlake8 checks to cover the test suite. (The benefit of the latter is that it could reveal areas where the checks ought to be configured differently.) I plan to open such a PR shortly.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp