Skip to content

entorb/template-python

Repository files navigation

Torben's Python Template

My Python template repo, using the following tools:

UV package manager

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 sync

see update.sh

Pytest Unit Tests

# 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

Ruff formatter and linter

  • config in ruff.toml
  • run_ruff.sh
  • or uv run ruff format and uv run ruff check --fix or even uv run ruff check --fix --unsafe-fixes

To disable a certain rule

  • for a file add # ruff: noqa: D103 at the top
  • for a specific line append # noqa: D103

GitHub Actions

SonarQube Code Analysis

Using GitHub Action to scan and provide unit test coverage report

see check.yml

Pre-commit

see https://pre-commit.com

# 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

CSpell Code Checker

(run by pre-commit and VSCode)

see https://cspell.org and cspell.org/configuration/document-settings/

To disable cspell checking of a file or path, you can use

  • add a # cspell: disable comment inside that file
  • exclude via cspell.config.yaml -> ignorePaths

To disable the spellchecking for a section of the file

# cspell: disable
# ...
# cspell: enable

To disable for a single line # cspell:disable-next-line

Ignore words per file

  • # cspell:ignore myword myyword add to file-specifiv ignore list
  • # cspell:words myword myyword add to file-specifiv dictionary
  • # cspell:ignoreRegExp g{5}|h{5}

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors