Pycodestyle 2.11.1 breaks flake8 5.0.4 in noble

Bug #2053217 reported by Marco A. Gutierrez
18
This bug affects 4 people
Affects Status Importance Assigned to Milestone
pycodestyle (Ubuntu)
Confirmed
Undecided
Unassigned

Bug Description

The update of pycodestyle to version 2.11.1 seems to break the current flake8 at version 5.0.4 at noble.

What happens:
Flake8 5.0.4 tries to import missing_whitespace_around_operator here: https://github.com/PyCQA/flake8/blob/5.0.4/src/flake8/plugins/pycodestyle.py#L25 which is not available in pycodestyle 2.11.1 anymore due to the changes from https://github.com/PyCQA/pycodestyle/commit/f04e2a1f5d37f8668519f123b97bf38165994b72.

The latest pycodestyle that seems to have missing_whitespace_around_operator seems to be 2.10.0: https://github.com/PyCQA/pycodestyle/blob/2.10.0/pycodestyle.py#L842 while the soonest flake8 that removes the import seems to be 6.0.1: https://github.com/PyCQA/flake8/blob/7ef0350a439c93166bc8ba89fcc3de6a9a664e6c/src/flake8/plugins/pycodestyle.py#L25.

Possible fix: Either downgrade pycodestyle to 2.10.0 or upgrade flake8 to 6.0.1, looking at version numbers the former might bring less breaking changes in but I'm not sure how this plays out with the plans to bring python3.12 into noble.

Steps to Reproduce:

OS:
Description: Ubuntu Noble Numbat (development branch)
Release: 24.04
Packages:
flake8:
  Installed: (none)
  Candidate: 5.0.4-4
  Version table:
     5.0.4-4 500
        500 http://archive.ubuntu.com/ubuntu noble/universe amd64 Packages
pycodestyle:
  Installed: 2.11.1-1
  Candidate: 2.11.1-1
  Version table:
 *** 2.11.1-1 500
        500 http://archive.ubuntu.com/ubuntu noble/universe amd64 Packages
        100 /var/lib/dpkg/status

Commands:
$python3
>>> from flake8.api.legacy import get_style_guide
>>> get_style_guide()
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/flake8/plugins/finder.py", line 296, in _load_plugin
    obj = plugin.entry_point.load()
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/importlib/metadata/__init__.py", line 202, in load
    module = import_module(match.group('module'))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/usr/lib/python3/dist-packages/flake8/plugins/pycodestyle.py", line 25, in <module>
    from pycodestyle import missing_whitespace_around_operator as _missing_whitespace_around_operator # noqa: E501
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ImportError: cannot import name 'missing_whitespace_around_operator' from 'pycodestyle' (/usr/lib/python3/dist-packages/pycodestyle.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/flake8/api/legacy.py", line 214, in get_style_guide
    application.find_plugins(
  File "/usr/lib/python3/dist-packages/flake8/main/application.py", line 128, in find_plugins
    self.plugins = finder.load_plugins(raw, opts)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/flake8/plugins/finder.py", line 370, in load_plugins
    return _classify_plugins(_import_plugins(plugins, opts), opts)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/flake8/plugins/finder.py", line 312, in _import_plugins
    return [_load_plugin(p) for p in plugins]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/flake8/plugins/finder.py", line 312, in <listcomp>
    return [_load_plugin(p) for p in plugins]
            ^^^^^^^^^^^^^^^
  File "/usr/lib/python3/dist-packages/flake8/plugins/finder.py", line 298, in _load_plugin
    raise FailedToLoadPlugin(plugin.package, e)
flake8.exceptions.FailedToLoadPlugin: Flake8 failed to load plugin "pycodestyle" due to cannot import name 'missing_whitespace_around_operator' from 'pycodestyle' (/usr/lib/python3/dist-packages/pycodestyle.py).

Tags: noble
Revision history for this message
Marco A. Gutierrez (marcogg) wrote :

Update:

It seems that python_3000_async_await_keywords needed here by flake8 5.0.4:

https://github.com/PyCQA/flake8/blob/5.0.4/src/flake8/plugins/pycodestyle.py#L27

is also gone in pycodestyle 2.11.0:

https://github.com/PyCQA/pycodestyle/blob/2.11.0/pycodestyle.py

Revision history for this message
Jose Luis Rivero (j-rivero) wrote (last edit ):

> Possible fix: Either downgrade pycodestyle to 2.10.0 or upgrade flake8 to 6.0.1

If that is correct, 6.1.0-1 is in noble-proposed so probably will land on noble/universe in the next days. I don't think that we need to do anything more at this point.

https://launchpad.net/ubuntu/+source/python-flake8

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in pycodestyle (Ubuntu):
status: New → Confirmed
Revision history for this message
Bin Li (binli) wrote :

Now flake8 in proposed is 7.0.0-1, after install these packages, it works fine in my side.

sudo apt install flake8=7.0.0-1 python3-flake8=7.0.0-1 python3-pyflakes=3.2.0-1

Revision history for this message
Ilya Maximets (i-maximets) wrote :

So 7.0.0-1 is in 'proposed' for more than a month now. Do we know when it will actually be released?
At this point default installation of flake8 is still 5.0 and it just doesn't work at all.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.