Template for a typed-checked, lint-ed, and formatted Python project.
Setup using the standard pyproject.toml and managed via Astral uv
It sets up:
- Astral uv
- Pyright Type Checker
- Ruff Linter and Formatter
- pre-commit
- pytest
Run code
uv run src/main.pyYou'll need some tools to be able to use the environment properly.
https://docs.astral.sh/uv/getting-started/installation
On windows:
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"On mac or linux:
curl -LsSf https://astral.sh/uv/install.sh | shAct is a tool to run GitHub Actions locally. It's not mandatory, but it's very useful to test the CI pipeline locally.
Follow the instructions to install it on your system: https://nektosact.com/installation/index.html
Run pre-commit hooks, that will format, lint and type check your code
uv run pre-commit run --all-filesThis step is not included in the pre-commit hooks to avoid disrupting the developer's workflow and to encourage frequent commits
Run tests
uv run pytest -vThis is already done by pre-commit, but you can run it manually if you want to. Run formatter
uv run ruff format .Run linter
uv run ruff check .It is ran in the CI pipeline, but you can run it locally if you want to.
Run type checker
uv run pyrightRun the CI locally using act
act