1

I am configuring my pyproject.toml so that bandit excludes the test files but it gives me the error ERROR pyproject.toml : toml parser not available, reinstall with toml extra

this is my pyproject.toml

[tool.bandit]
exclude_dirs = ["*/test/*"]
tests = ["B201", "B301"]
skips = ["B101", "B601"]

[tool.pre-commit-hooks.bandit]
exclude = ["test*"]

And I run the following command: bandit -c pyproject.toml -r .

anthony sottile
  • 61,815
  • 15
  • 148
  • 207
Aldo Matus
  • 61
  • 6

1 Answers1

3

I solved the problem by adding to my requirements.txt bandit[toml]==1.7.4 to get it to work

bandit[toml]==1.7.4

and if you are working with pre-commit:

-   repo:  https://github.com/PyCQA/bandit
    rev: 1.7.4
    hooks:
    -   id: bandit
        args: ["-c", "pyproject.toml"]
        additional_dependencies: [".[toml]"]
anthony sottile
  • 61,815
  • 15
  • 148
  • 207
Aldo Matus
  • 61
  • 6
  • pre-commit config example can be found in the [bandit docs](https://bandit.readthedocs.io/en/latest/config.html#bandit-settings) at the end of the Bandit Settings section. – Ledorub May 12 '23 at 13:12