Closed xqt closed 1 year ago
It's a known issue that flake8 relies on the deprecated interfaces removed in importlib_metadata 5. I've attempted to engage with the maintainers of that project, but they refuse to engage and dismiss my proposals without suggesting alternatives. Flake8 does declare a dependency on importlib_metadata<4.3
, so the fact that an incompatible version of importlib_metadata is being installed is probably an issue with the environment setup.
I do see that I can replicate the issue with pip install hacking
(via pip-run):
draft $ docker run -it jaraco/multipy-tox py -3.7 -m pip-run hacking -- -c pass
Collecting hacking
Downloading hacking-4.1.0-py3-none-any.whl (42 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 42.2/42.2 kB 1.6 MB/s eta 0:00:00
Collecting flake8<3.9.0,>=3.8.0
Downloading flake8-3.8.4-py2.py3-none-any.whl (72 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 72.9/72.9 kB 8.9 MB/s eta 0:00:00
Collecting mccabe<0.7.0,>=0.6.0
Downloading mccabe-0.6.1-py2.py3-none-any.whl (8.6 kB)
Collecting pycodestyle<2.7.0,>=2.6.0a1
Downloading pycodestyle-2.6.0-py2.py3-none-any.whl (41 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 41.4/41.4 kB 12.4 MB/s eta 0:00:00
Collecting importlib-metadata
Downloading importlib_metadata-5.0.0-py3-none-any.whl (21 kB)
Collecting pyflakes<2.3.0,>=2.2.0
Downloading pyflakes-2.2.0-py2.py3-none-any.whl (66 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 67.0/67.0 kB 16.6 MB/s eta 0:00:00
Collecting typing-extensions>=3.6.4
Using cached typing_extensions-4.3.0-py3-none-any.whl (25 kB)
Collecting zipp>=0.5
Downloading zipp-3.8.1-py3-none-any.whl (5.6 kB)
Installing collected packages: mccabe, zipp, typing-extensions, pyflakes, pycodestyle, importlib-metadata, flake8, hacking
Successfully installed flake8-3.8.4 hacking-4.1.0 importlib-metadata-5.0.0 mccabe-0.6.1 pycodestyle-2.6.0 pyflakes-2.2.0 typing-extensions-4.3.0 zipp-3.8.1
Even though flake8 pins importlib_metadata on Python 3.7, pip installs importlib_metadata 5.
Interestingly, if I install only flake8~=4.0.1
(the sole dependency of hacking) using the same command, the declared version of importlib_metadata is pulled:
draft $ docker run -it jaraco/multipy-tox py -3.7 -m pip-run 'flake8~=4.0.1' -- -c pass
Collecting flake8~=4.0.1
Downloading flake8-4.0.1-py2.py3-none-any.whl (64 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 64.1/64.1 kB 2.1 MB/s eta 0:00:00
Collecting mccabe<0.7.0,>=0.6.0
Downloading mccabe-0.6.1-py2.py3-none-any.whl (8.6 kB)
Collecting pycodestyle<2.9.0,>=2.8.0
Downloading pycodestyle-2.8.0-py2.py3-none-any.whl (42 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 42.1/42.1 kB 9.7 MB/s eta 0:00:00
Collecting pyflakes<2.5.0,>=2.4.0
Downloading pyflakes-2.4.0-py2.py3-none-any.whl (69 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 69.7/69.7 kB 17.2 MB/s eta 0:00:00
Collecting importlib-metadata<4.3
Downloading importlib_metadata-4.2.0-py3-none-any.whl (16 kB)
Collecting zipp>=0.5
Downloading zipp-3.8.1-py3-none-any.whl (5.6 kB)
Collecting typing-extensions>=3.6.4
Using cached typing_extensions-4.3.0-py3-none-any.whl (25 kB)
Installing collected packages: mccabe, zipp, typing-extensions, pyflakes, pycodestyle, importlib-metadata, flake8
Successfully installed flake8-4.0.1 importlib-metadata-4.2.0 mccabe-0.6.1 pycodestyle-2.8.0 pyflakes-2.4.0 typing-extensions-4.3.0 zipp-3.8.1
I guess there may be an issue with how pip resolves dependencies of dependencies.
Oh, I see a difference. When installing hacking
from a wheel, it gets 4.1.0, which depends on flake8 3.8.x and flake8 3.8.x doesn't pin importlib_metadata.
There's nothing that can be done here from the perspective of importlib_metadata. The deprecation has been in place since Feb 2021 and other projects have been able to adapt to the transition. These issues were anticipated and socialized and this project has worked actively with affected projects to provide multiple avenues to navigate the transition. I'm still willing to help flake8 support the preferred interfaces. What's not going to happen is to undo the deprecation or restore support for these deprecated interfaces indefinitely (or for many years).
As a user of flake8, your best option is probably to preemptively install importlib_metadata<5
until flake8 can adapt.
@jaraco @xqt I filed an issue on the flake8 side here: https://github.com/PyCQA/flake8/issues/1701
Workaround is as @jaraco says above, pin importlib_metadata
to <5
for now.
The new import_meta_data 5.0.0 fails with hacking flake8 extension:
See CI test here
It works with the previous release 4.13.0: