This template bundles a rich toolchain for quality, productivity, and release automation.
- Very fast installs (10–100x faster than pip)
- Manages envs, deps, and packages in one tool
- Rust-based by astral-sh; PyPI compatible
Common commands:
uv sync --all-extras # install deps
uv add package-name # add runtime dep
uv add --dev package-name # add dev dep
uv remove package-name # remove dep
uv run python script.py # run commands
uv run pytest
uv tree # dependency tree
uv pip compile pyproject.toml # export requirements- Mature ecosystem and plugins
- Strong version management
poetry install
poetry add package-name
poetry add --group dev package-name
poetry remove package-name
poetry update
poetry run python script.py
poetry run pytest- Auto-format Python; config in
.pre-commit-config.yaml
black src/ tests/
black --check src/
black --include \.ipynb$ notebooks/- Rust-fast linter/formatter; replaces flake8/isort/pyupgrade
ruff check src/
ruff check --fix src/
ruff format src/
pre-commit run ruff --all-files
pre-commit run ruff-format --all-filesConfig: [tool.ruff] in pyproject.toml.
flake8 src/ tests/
flake8 src/core/exp.pyisort src/ tests/
isort --check src/mypy src/
mypy --ignore-missing-imports src/Example annotation:
def greet(name: str) -> str:
"""Greet someone by name."""
return f"Hello, {name}!"interrogate src/
interrogate --fail-under=80 src/
interrogate --verbose src/Example docstring in practice shown in code block in zh version.
pytest # all tests
pytest tests/test_core.py # file
pytest tests/test_core.py::test_example # single test
pytest -v # verbose
pytest --cov=src --cov-report=html
pytest --lf # last failed
pytest -n auto # parallelSample test:
import pytest
from src.core.example import Example
def test_example():
"""Test example functionality."""
example = Example(42)
assert example.get_value() == 42tox # all envs
tox -e py311 # specific env
tox -p # parallel
tox list # list envspytest --alluredir=tmp/allure_results
make report
# or
allure serve tmp/allure_resultsuv run mkdocs serve # dev server
uv run mkdocs build # static build
uv run mike deploy 3.10 # deploy with mikeuv run jupyter lab
uv run jupyter notebook
nbstripout --keep-outputpre-commit install
pre-commit run --all-files
pre-commit run black --all-files
# skip (not recommended)
git commit --no-verifyimport cProfile
from snakeviz.cli import main
profiler = cProfile.Profile()
profiler.enable()
# run your code
profiler.disable()
profiler.dump_stats("tmp/profile.stats")
main(["tmp/profile.stats"])- Automated versioning and releases
- Config:
release-please-config.json - Flow: push to
main→ release PR → merge → release + tag → Actions publish
- Install pre-commit hooks locally
- Ensure CI runs: pre-commit, pytest, interrogate, tox
- Keep tool versions aligned across the team
- Prefer Ruff over Flake8 for speed; uv over pip
- For tool conflicts, align configs or consolidate on Ruff
- Common errors:
command not found: uv: ensure installedModuleNotFoundError: activate venv and install deps