python-project-template is a starter template for Python projects with advanced setup for code quality tools, static analysis, formatting, documentation checks, and dependency security auditing.
This template includes configurations for poetry, ruff, black, mypy, pylint, pre-commit, and other popular tools, along with a ready-to-use Taskfile.yml for convenient task management.
- Python 3.12+
- Poetry
- Docker (optional)
- Task (optional)
The project comes pre-configured with:
- Code formatting via
black,isort,ruff - Static code analysis using
ruff,mypy,pylint - Docstring style checks via
interrogate - Dead code detection with
vulture - Dependency vulnerability auditing using
pip-audit - Unused library checks via
deptry pre-commithooks setup for Git
All settings target Python 3.12+ with a max line length of 88 characters.
-
Make sure you have Python 3.12 or newer installed.
-
Install dependencies:
poetry install --no-root
-
Install Git hooks via pre-commit:
poetry run pre-commit install
-
Run the application (example module
app.main):poetry run python -m app.main
-
Build the Docker image:
docker build -t python-app . -
Run the container:
docker run -it --rm python-app
To simplify project tasks, you can use the included Taskfile.yml:
-
Install dependencies:
task install
-
Format code:
task format
-
Run linting and static analysis:
task lint
-
Check docstring style:
task docstyle
-
Find dead code:
task deadcode
-
Audit dependencies for vulnerabilities:
task audit
-
Run full check (formatting, linting, auditing, etc.):
task check
-
Run the application:
task run
-
Build and run Docker container:
task docker
This project is licensed under the MIT License. See the LICENSE file for details.