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

Flake8 extension crashing #130

Closed
bmakan opened this issue Mar 10, 2023 · 1 comment
Closed

Flake8 extension crashing #130

bmakan opened this issue Mar 10, 2023 · 1 comment

Comments

@bmakan
Copy link

bmakan commented Mar 10, 2023

I've installed the extension for the first time to see how it works as opposed to the native flake8 linting. But nothing was happening. I found an error in there (see trace below).

Without the extension, the linting works correctly. I use multiple flake8 plugins (https://github.com/wemake-services/wemake-python-styleguide to be exact).

2023-03-10 08:51:47.775 [info] [Error - 8:51:47 AM] Linting failed with error:
Traceback (most recent call last):
  File "/home/bmakan/.vscode-server/extensions/ms-python.flake8-2023.4.0/bundled/libs/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 1206, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1149, 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 "/home/bmakan/python-venvs/athenaeum/lib/python3.11/site-packages/flake8_bandit.py", line 10, in <module>
    from flake8.options.config import ConfigFileFinder
ImportError: cannot import name 'ConfigFileFinder' from 'flake8.options.config' (/home/bmakan/.vscode-server/extensions/ms-python.flake8-2023.4.0/bundled/libs/flake8/options/config.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/bmakan/.vscode-server/extensions/ms-python.flake8-2023.4.0/bundled/tool/lsp_server.py", line 108, in _linting_helper
    result = _run_tool_on_document(document, use_stdin=False)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/bmakan/.vscode-server/extensions/ms-python.flake8-2023.4.0/bundled/tool/lsp_server.py", line 543, in _run_tool_on_document
    result = utils.run_module(
             ^^^^^^^^^^^^^^^^^
  File "/home/bmakan/.vscode-server/extensions/ms-python.flake8-2023.4.0/bundled/tool/lsp_utils.py", line 139, in run_module
    return _run_module(module, argv, use_stdin, source)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/bmakan/.vscode-server/extensions/ms-python.flake8-2023.4.0/bundled/tool/lsp_utils.py", line 126, in _run_module
    runpy.run_module(module, run_name="__main__")
  File "<frozen runpy>", line 229, in run_module
  File "<frozen runpy>", line 88, in _run_code
  File "/home/bmakan/.vscode-server/extensions/ms-python.flake8-2023.4.0/bundled/libs/flake8/__main__.py", line 5, in <module>
    raise SystemExit(main())
                     ^^^^^^
  File "/home/bmakan/.vscode-server/extensions/ms-python.flake8-2023.4.0/bundled/libs/flake8/main/cli.py", line 22, in main
    app.run(argv)
  File "/home/bmakan/.vscode-server/extensions/ms-python.flake8-2023.4.0/bundled/libs/flake8/main/application.py", line 336, in run
    self._run(argv)
  File "/home/bmakan/.vscode-server/extensions/ms-python.flake8-2023.4.0/bundled/libs/flake8/main/application.py", line 324, in _run
    self.initialize(argv)
  File "/home/bmakan/.vscode-server/extensions/ms-python.flake8-2023.4.0/bundled/libs/flake8/main/application.py", line 302, in initialize
    self.find_plugins(
  File "/home/bmakan/.vscode-server/extensions/ms-python.flake8-2023.4.0/bundled/libs/flake8/main/application.py", line 128, in find_plugins
    self.plugins = finder.load_plugins(raw, opts)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/bmakan/.vscode-server/extensions/ms-python.flake8-2023.4.0/bundled/libs/flake8/plugins/finder.py", line 370, in load_plugins
    return _classify_plugins(_import_plugins(plugins, opts), opts)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/bmakan/.vscode-server/extensions/ms-python.flake8-2023.4.0/bundled/libs/flake8/plugins/finder.py", line 312, in _import_plugins
    return [_load_plugin(p) for p in plugins]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/bmakan/.vscode-server/extensions/ms-python.flake8-2023.4.0/bundled/libs/flake8/plugins/finder.py", line 312, in <listcomp>
    return [_load_plugin(p) for p in plugins]
            ^^^^^^^^^^^^^^^
  File "/home/bmakan/.vscode-server/extensions/ms-python.flake8-2023.4.0/bundled/libs/flake8/plugins/finder.py", line 298, in _load_plugin
    raise FailedToLoadPlugin(plugin.package, e)
flake8.exceptions.FailedToLoadPlugin: Flake8 failed to load plugin "flake8-bandit" due to cannot import name 'ConfigFileFinder' from 'flake8.options.config' (/home/bmakan/.vscode-server/extensions/ms-python.flake8-2023.4.0/bundled/libs/flake8/options/config.py).

System info:

Extension version: 2023.4.0
VS Code version: Code 1.76.1 (5e805b79fcb6ba4c2d23712967df89a089da575b, 2023-03-08T16:32:00.131Z)
OS version: Windows_NT x64 10.0.19044
Modes:
Sandboxed: No
Remote OS version: Linux x64 5.4.0-131-generic
Remote OS version: Linux x64 3.10.0-1062.18.1.el7.x86_64

@karthiknadig
Copy link
Member

@bmakan This is an issue with flake8_bandit see tylerwince/flake8-bandit#41 . flake8 version 5.0.0 dropped support for ConfigFileFinder.

Try the following, and it might work for your case:

  1. Install flake8 version 4.0.1 in your environment.
  2. Install flake8_bandit.
  3. Set flake8.importStrategy to fromEnvironment

@karthiknadig karthiknadig closed this as not planned Won't fix, can't repro, duplicate, stale Mar 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants