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

BanditNodeVisitor.__init__() missing 1 required positional argument: 'metrics' #835

Closed
Crocmagnon opened this issue Feb 28, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@Crocmagnon
Copy link

Crocmagnon commented Feb 28, 2022

Describe the bug

Using the latest version from bandit (in our case in pre-commit with flake8-bandit) fails as of today with the following traceback:

multiprocessing.pool.RemoteTraceback: 
"""
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/usr/local/lib/python3.10/multiprocessing/pool.py", line 48, in mapstar
    return list(map(*args))
  File "/root/.cache/pre-commit/repohnaochc9/py_env-python3/lib/python3.10/site-packages/flake8/checker.py", line 687, in _run_checks
    return checker.run_checks()
  File "/root/.cache/pre-commit/repohnaochc9/py_env-python3/lib/python3.10/site-packages/flakehell/_patched/_checkers.py", line 282, in run_checks
    return super().run_checks()
  File "/root/.cache/pre-commit/repohnaochc9/py_env-python3/lib/python3.10/site-packages/flake8/checker.py", line 597, in run_checks
    self.run_ast_checks()
  File "/root/.cache/pre-commit/repohnaochc9/py_env-python3/lib/python3.10/site-packages/flake8/checker.py", line 500, in run_ast_checks
    for (line_number, offset, text, _) in runner:
  File "/root/.cache/pre-commit/repohnaochc9/py_env-python3/lib/python3.10/site-packages/flake8_bandit.py", line 85, in run
    for warn in self._check_source():
  File "/root/.cache/pre-commit/repohnaochc9/py_env-python3/lib/python3.10/site-packages/flake8_bandit.py", line 59, in _check_source
    bnv = BanditNodeVisitor(
TypeError: BanditNodeVisitor.__init__() missing 1 required positional argument: 'metrics'
"""
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "/root/.cache/pre-commit/repohnaochc9/py_env-python3/bin/flakehell", line 8, in <module>
    sys.exit(entrypoint())
  File "/root/.cache/pre-commit/repohnaochc9/py_env-python3/lib/python3.10/site-packages/flakehell/_cli.py", line 40, in entrypoint
    exit_code, msg = main(argv)
  File "/root/.cache/pre-commit/repohnaochc9/py_env-python3/lib/python3.10/site-packages/flakehell/_cli.py", line 32, in main
    return COMMANDS[command_name](argv=argv[1:])
  File "/root/.cache/pre-commit/repohnaochc9/py_env-python3/lib/python3.10/site-packages/flakehell/commands/_lint.py", line 12, in lint_command
    app.run(argv)
  File "/root/.cache/pre-commit/repohnaochc9/py_env-python3/lib/python3.10/site-packages/flake8/main/application.py", line 375, in run
    self._run(argv)
  File "/root/.cache/pre-commit/repohnaochc9/py_env-python3/lib/python3.10/site-packages/flake8/main/application.py", line 364, in _run
    self.run_checks()
  File "/root/.cache/pre-commit/repohnaochc9/py_env-python3/lib/python3.10/site-packages/flake8/main/application.py", line 271, in run_checks
    self.file_checker_manager.run()
  File "/root/.cache/pre-commit/repohnaochc9/py_env-python3/lib/python3.10/site-packages/flake8/checker.py", line 309, in run
    self.run_parallel()
  File "/root/.cache/pre-commit/repohnaochc9/py_env-python3/lib/python3.10/site-packages/flake8/checker.py", line 275, in run_parallel
    for ret in pool_map:
  File "/usr/local/lib/python3.10/multiprocessing/pool.py", line 448, in <genexpr>
    return (item for chunk in result for item in chunk)
  File "/usr/local/lib/python3.10/multiprocessing/pool.py", line 870, in next
    raise value
TypeError: BanditNodeVisitor.__init__() missing 1 required positional argument: 'metrics'

flake8-bandit hasn't been updated recently.

Reproduction steps

I sadly wasn't able to produce a MWE. Here's our relevant pre-commit config though:

  - repo: https://github.com/mcarans/flakehell
    rev: 1b84f4dd6c16232b5c0c6206511427676ab55f5b
    hooks:
      - id: flakehell
        additional_dependencies:
          - flake8-annotations-complexity
          - flake8-bandit
          - flake8-builtins
          - flake8-bugbear
          - flake8-comprehensions
          - flake8-docstrings
          - flake8-eradicate
          - flake8-noqa
          - pep8-naming

Expected behavior

The exception isn't raised and the check doesn't fail.

Bandit version

1.7.3 (latest on PyPI)

Python version

3.10 (Default)

Additional context

@Crocmagnon Crocmagnon added the bug Something isn't working label Feb 28, 2022
@Crocmagnon
Copy link
Author

Crocmagnon commented Feb 28, 2022

Doesn't happen when running with flakeheaven instead of flakehell, I'm closing this bug report. Sorry for the noise.

@sscherfke
Copy link

This is also an issue with flake8-bandit: tylerwince/flake8-bandit#21

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants