GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — flake8 pre-commit config incompatible with 3.12 · Issue #1670 · gitpython-developers/GitPython

flake8 pre-commit config incompatible with 3.12 #1670

New issue
Copy link
New issue
Copy link
Closed
#1673
Closed
flake8 pre-commit config incompatible with 3.12#1670
#1673
Copy link
Labels
acknowledgedhelp wanted
Milestone
v3.1.37 - Bugfixes

Description

@EliahKagan
EliahKagan
opened on Sep 21, 2023
Issue body actions

The configuration for flake8 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-files
flake8...................................................................Failed
- hook id: flake8
- exit code: 1

git/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 operator
2     E231 missing whitespace after ':'
3

check for merge conflicts................................................Passed
check toml...............................................................Passed
check 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 because flake8 6.0.0 depends on pycodestyle 2.10.*, which implements that check (E231) and has a parsing bug specific to Python 3.12. This was fixed in PyCQA/pycodestyle#1148.

Upgrading to flake8 6.1.0 gets the fix, since that version of flake8, currently the latest, depends on pycodestyle 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: 1

git/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 operator
2     E721 do not compare types, for exact checks use `is` / `is not`, for instance checks use `isinstance()`
3

check for merge conflicts................................................Passed
check toml...............................................................Passed
check yaml...............................................................Passed

However, that reports E721 about the use of == to compare to a type 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 by flake8, also bumps versions on the listed flake8 plugins (other than the default ones like pycodestyle) and fixes new warnings from that, and possibly addresses other style issues and/or expands the scope of flake8 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.

Activity

  1. Byron
    added
    acknowledged
    help wanted
    on Sep 21, 2023
  2. Byron
    closed this as completedin #1673on Sep 21, 2023
  3. Byron
    added this to the v3.1.37 - Bugfixes milestone on Sep 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    acknowledgedhelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      • v3.1.37 - Bugfixes

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.