python-app-template
A template with a reasonable basic setup, including:
- black (formatting)
- flake8 (linting)
- mypy (type checking)
- isort (import sorting)
- pre-commit (check/fix the things above and more on each commit)
- poetry (dependency and venv management)
- pytest (testing)
- tox (test against multiple Python versions even locally)
- pytest-cov (compute coverage, uploaded to codecov.io)
- pdoc3 (generate documentation, deployed to Github Pages)
Inspired by Hypermodern Python and blog posts like this. You can look there for more tools and other choices.
- If you are building a CLI app, consider using Typer
- If you are building a web app, consider using FastAPI
Setup
- Change the package name and path to the repository everywhere
- configure Github Pages in the settings
- and set tokens in the CI if the repository is not public
Development
This project uses Poetry for dependency management.
Clone this repository and run poetry install
.
Run pre-commit install
to enable pre-commit hooks for linting and sanity checks.
To locally generate documentation, run pdoc -o docs python_app_template
.
To locally run tests and get coverage information, use pytest --cov
.
To run the tests with different Python versions, run tox
. For that, you should install the Python versions in the .python-version
file. You can use pyenv to do that and switch between them as you please.