exclude did not work for me, so I looked through official docs and found this:

We can specify dirs (and files as well) that we want to exclude in a list format
pyproject.toml:
[tool.bandit]
exclude_dirs = ["venv",]
From this documentation:
"Also you can configure bandit via pyproject.toml file. In this case you would explicitly specify the path to configuration via -c too."
Therefore, CLI option would look like this:
bandit -v -r . -c "pyproject.toml"
(will work without quotes as well)

I've never used bandit before, so if I got your question wrong - please feel free to write back, we will figure that out :D
Answer from barni on Stack Overflowexclude did not work for me, so I looked through official docs and found this:

We can specify dirs (and files as well) that we want to exclude in a list format
pyproject.toml:
[tool.bandit]
exclude_dirs = ["venv",]
From this documentation:
"Also you can configure bandit via pyproject.toml file. In this case you would explicitly specify the path to configuration via -c too."
Therefore, CLI option would look like this:
bandit -v -r . -c "pyproject.toml"
(will work without quotes as well)

I've never used bandit before, so if I got your question wrong - please feel free to write back, we will figure that out :D
To exclude directory venv, this command works fine for me :
bandit -r . -x */venv/*
I think this is an issue of bandit that I found here. I think you should use the absolute path to .venv as follows:
poetry run bandit --exclude "./absolute/path/.venv" -r .
Use the absolute path in the config file too:
[tool.bandit]
targets = "my_package"
exclude = "./absolute/path/.venv" #
if you have defined the .pre-commit-config.yaml here is working sample to ignore multiple dirs:
- repo: local
hooks:
- id: bandit
name: python-bandit-vulnerability-check
entry: bandit
args: [ '-r', '.', '-x', 'env, venv' ]
language: system
pass_filenames: false
» pip install pyproject-pre-commit