Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatible with flake8 5.0.0 ? #115

Closed
banesullivan opened this issue Jul 30, 2022 · 6 comments · Fixed by #116
Closed

Incompatible with flake8 5.0.0 ? #115

banesullivan opened this issue Jul 30, 2022 · 6 comments · Fixed by #116

Comments

@banesullivan
Copy link

flake8 5.0.0 was just released and I'm seeing CI failures from flake8-isort:

Linting with flake8
flake8 --ignore=E501 localtileserver tests
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/flake8/plugins/finder.py", line 289, in _load_plugin
    obj = plugin.entry_point.load()
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/importlib/metadata.py", line 77, in load
    module = import_module(match.group('module'))
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/importlib/__init__.py", line [12](https://github.com/banesullivan/localtileserver/runs/7594180819?check_suite_focus=true#step:5:13)7, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 843, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/opt/hostedtoolcache/Python/3.8.[13](https://github.com/banesullivan/localtileserver/runs/7594180819?check_suite_focus=true#step:5:14)/x64/lib/python3.8/site-packages/flake8_isort.py", line 3, in <module>
    from isort import SortImports
ImportError: cannot import name 'SortImports' from 'isort' (/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/isort/__init__.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.8.13/x64/bin/flake8", line 8, in <module>
    sys.exit(main())
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/flake8/main/cli.py", line [22](https://github.com/banesullivan/localtileserver/runs/7594180819?check_suite_focus=true#step:5:23), in main
    app.run(argv)
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/flake8/main/application.py", line 336, in run
    self._run(argv)
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/flake8/main/application.py", line 3[24](https://github.com/banesullivan/localtileserver/runs/7594180819?check_suite_focus=true#step:5:25), in _run
    self.initialize(argv)
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/flake8/main/application.py", line 302, in initialize
    self.find_plugins(
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/flake8/main/application.py", line 1[28](https://github.com/banesullivan/localtileserver/runs/7594180819?check_suite_focus=true#step:5:29), in find_plugins
    self.plugins = finder.load_plugins(raw, opts)
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/flake8/plugins/finder.py", line 363, in load_plugins
    return _classify_plugins(_import_plugins(plugins, opts), opts)
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/flake8/plugins/finder.py", line 305, in _import_plugins
    return [_load_plugin(p) for p in plugins]
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/flake8/plugins/finder.py", line 305, in <listcomp>
    return [_load_plugin(p) for p in plugins]
  File "/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/flake8/plugins/finder.py", line [29](https://github.com/banesullivan/localtileserver/runs/7594180819?check_suite_focus=true#step:5:30)1, in _load_plugin
    raise FailedToLoadPlugin(plugin.package, e)
flake8.exceptions.FailedToLoadPlugin: Flake8 failed to load plugin "flake8-isort" due to cannot import name 'SortImports' from 'isort' (/opt/hostedtoolcache/Python/3.8.13/x64/lib/python3.8/site-packages/isort/__init__.py).
@junaruga
Copy link

This part is related to supporting flake8 5.0.0.

'flake8 >= 3.2.1, <5',

In my environment, I was using flake8-isort with flake8.

$ cat test-lint-requirements.txt
# Code Analysis for Python
flake8
flake8-colors
flake8-isort
isort
pydocstyle
# The pep8-naming is used as a plugin for flake8
pep8-naming
# Code Analysis for Bash
bashate

Then it seems the flake8-isort 3.0.0 was installed with flake8 5.0.0.

lint-py3 installdeps: -rtest-lint-requirements.txt
lint-py3 installed: bashate==2.1.0,flake8==5.0.0,flake8-colors==0.1.9,flake8-isort==3.0.0,isort==5.10.1,mccabe==0.7.0,pbr==5.9.0,pep8-naming==0.13.1,pycodestyle==2.9.0,pydocstyle==6.1.1,pyflakes==2.5.0,snowballstemmer==2.2.0,testfixtures==7.0.0
lint-py3 run-test-pre: PYTHONHASHSEED='3496060749'
lint-py3 run-test: commands[0] | flake8 --version
Traceback (most recent call last):
  File "/work/.tox/lint-py3/lib/python3.10/site-packages/flake8/plugins/finder.py", line 289, in _load_plugin
    obj = plugin.entry_point.load()
  File "/usr/lib64/python3.10/importlib/metadata/__init__.py", line 171, in load
    module = import_module(match.group('module'))
  File "/usr/lib64/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/work/.tox/lint-py3/lib/python3.10/site-packages/flake8_isort.py", line 3, in <module>
    from isort import SortImports
ImportError: cannot import name 'SortImports' from 'isort' (/work/.tox/lint-py3/lib/python3.10/site-packages/isort/__init__.py)

@nhymxu
Copy link
Contributor

nhymxu commented Aug 1, 2022

I create new PR to fix this. Wait @gforcada check.

@rydenius
Copy link

rydenius commented Aug 1, 2022

Thank you for fixing this. The fact that newer flake8 major releases will make flake8-isort fall back to the 2+ years old 3.0.0 release is so confusing that it almost defeats the purpose of setting an upper bound at all.

@wiseaidev
Copy link

I am facing the same issue in pre-commit-ci. It seems like I opened the issue in the wrong repo. Came here from PyCQA/flake8/issues/1654.

@gforcada
Copy link
Owner

gforcada commented Aug 4, 2022

@wiseaidev you are fortunate and came at the right time: 4.2.0 is out with flake8 version 5 compatibility 🎉

@wiseaidev
Copy link

wiseaidev commented Aug 4, 2022

@gforcada, ayo! That was blazingly fast!
I can confirm it is now working with flake8 @ awesome-code/pull/17.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants