My Python template repo, using the following tools:
UV manages Python and package versions, as well as venv.
# run
uv run src/main.py
# update a package
uv lock --upgrade-package pytest
# uv lock --upgrade
uv syncsee update.sh
# for console output
uv run pytest --cov
# for html output in htmlcov/ dir
uv run pytest --cov --cov-report=html
# for sonarqube compatible report
uv run pytest tests/ --cov --cov-report=xml:coverage.xml- config in ruff.toml
- run_ruff.sh
- or
uv run ruff formatanduv run ruff check --fixor evenuv run ruff check --fix --unsafe-fixes
To disable a certain rule
- for a file add
# ruff: noqa: D103at the top - for a specific line append
# noqa: D103
- Report at sonarcloud.io
- Or per API as json
- disable the "Automatic Analysis" at https://sonarcloud.io/project/analysis_method?id=entorb_template-python
- setup SonarSource/sonarqube-scan-action@v5 in check.yml
- rename .sonarcloud.properties to sonar-project.properties
- generate a token at https://sonarcloud.io/account/security
- add this token as secret SONAR_TOKEN in GitHub
see check.yml
# run
uv run pre-commit run --all-files
# or ./scripts/run_pre-commit.sh
# auto-update all hooks
uv run pre-commit autoupdate
# to trigger pre-commit automatically at each `git commit` command
uv run pre-commit install(run by pre-commit and VSCode)
see https://cspell.org and cspell.org/configuration/document-settings/
- cspell.config.yaml config
- cspell-words.txt custom dictionary, add unknown words here
To disable cspell checking of a file or path, you can use
- add a
# cspell: disablecomment inside that file - exclude via cspell.config.yaml -> ignorePaths
To disable the spellchecking for a section of the file
# cspell: disable
# ...
# cspell: enableTo disable for a single line # cspell:disable-next-line
Ignore words per file
# cspell:ignore myword myywordadd to file-specifiv ignore list# cspell:words myword myywordadd to file-specifiv dictionary# cspell:ignoreRegExp g{5}|h{5}