A starter template for setting up a modern Python project
  • Makefile 57.1%
  • Python 42.9%
Find a file Use this template
2025-03-05 08:07:01 +01:00
.github Bump actions/checkout from 3 to 4 2023-09-11 11:56:19 +00:00
src/hello_world Replace flake8 and isort with ruff 2023-09-15 18:09:21 +02:00
tests Switch to MIT-0 license and remove copyright notice from all files 2022-08-30 08:20:46 +02:00
.gitignore Initial setup of project 2022-02-24 07:45:43 +01:00
.gitlab-ci.yml Switch to MIT-0 license and remove copyright notice from all files 2022-08-30 08:20:46 +02:00
Makefile Replace flake8 and isort with ruff 2023-09-15 18:09:21 +02:00
pyproject.toml Upgrade dependencies to latest versions 2025-03-05 08:07:01 +01:00
README.md Changed README to include Ruff instead of Flake8 2024-10-11 16:50:08 +02:00

Python Project Template

A nice starting point for a modern python project.

Licensing

This template is licensed under the MIT-0 license, meaning you're basically free to do whatever you want with it.

Requirements

Python

You need to have Python 3 installed (obviously), the exact version is configurable in pyproject.toml but defaults to 3.9+

Poetry

You also need to have Poetry installed, check the readme for instructions. Note though that some Linux distributions have a Poetry package available in which case you might want to install that instead.

  • Arch Linux (and derivatives): python-poetry
  • OpenSuse Tumbleweed: python310-poetry, python39-poetry, python38-poetry
  • Fedora: python3-poetry
  • Debian (Sid): python3-poetry

Technologies

Poetry

Poetry is a packaging and dependency manager for Python.

Ruff

Ruff is an extremely fast Python linter written in Rust.

Black

Black is an uncompromising code formatter for Python. It's designed to format code in a fashion that reduces merge conflicts.

isort

isort "isort your imports, so you don't have to."

Pytest

pytest Is the most popular testing framework for Python that isn't unittest. It integrates well with unittest and adds on a lot of powerful features for testing.

Make

Make is used for scripting the various tooling to make them easy to execute. The Makefile contains targets for each tooling as well as an init target for initialising the project and a ci target suitable for running in a CI pipeline.

Init

make init installs all projects using poetry

Format

make format runs Black and isort on src/ and tests/ to reformat all files and order imports.

Lint

make lint runs flake8 on src/ and tests/ and reports any linting errors, fails if there are any linting errors and succeeds otherwise.

Stylecheck

make stylecheck runs Black in check mode, reporting any changes that would be made instead of making them. Fails if any change would be made and succeeds if no changes would be made

Typecheck

make typecheck runs mypy on src/ and reports any type errors, fails if there is any type errors and succeeds otherwise.

Test

make test runs all tests in tests/ using PyTest, fails if there is any test failures and suceeds otherwise.

CI

make ci is a meta target that depends on stylecheck, lint, typecheck and test and fails if any of those targets fails.

CI

The templates comes pre-baked with CI support for both GitLab and GitHub. It contains one job that runs on pull requests and that runs the ci Make target.