PDM setup
pdm run pytest --cov=. --cov-report=xml tests
[tool.pdm.scripts]
cov = {shell = "pdm run pytest --cov=. --cov-report=xml tests"}
Add to your .bashrc or .zshrc
if [ -n "$PYTHONPATH" ]; then
export PYTHONPATH='/Users/pat/.asdf/installs/python/3.9.0/lib/python3.9/site-packages/pdm/pep582':$PYTHONPATH
else
export PYTHONPATH='/Users/pat/.asdf/installs/python/3.9.0/lib/python3.9/site-packages/pdm/pep582'
fi
Add to .vscode/settings.json
"python.autoComplete.extraPaths": ["${workspaceFolder}/__pypackages__/3.9/lib"],
"python.analysis.extraPaths": ["${workspaceFolder}/__pypackages__/3.9/lib"]
To work around this issue: Use of assert detected. The enclosed code will be removed when compiling to optimized byte code.
Create the following .bandit config at the root of the project:
[bandit]
exclude = tests/
targets = project/
To test bandit works, simply add assert True in both project.py and test_project.py. Then run:
bandit -r --ini .bandit
Observe the config is ignored and warnings keep being reported for both project.py and test_project.py.
Explicitly tell vscode to run bandit with its config:
{
"python.linting.enabled": true,
"python.linting.lintOnSave": true,
"python.linting.banditEnabled": true,
"python.linting.banditArgs": [
"-r",
"--ini",
".bandit"
],
}