- Makefile 57.1%
- Python 42.9%
| .github | ||
| src/hello_world | ||
| tests | ||
| .gitignore | ||
| .gitlab-ci.yml | ||
| Makefile | ||
| pyproject.toml | ||
| README.md | ||
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.