This project assumes using Unix-like operating system with Python, git and GNU Make installed. It assumes using
the default python for the machine, this can be changed by setting the PYTHON variable. To setup a project, copy
all the files to desired directory and run make dev.
- Makefile is used for automation of the dev workflow. The
makecommand runs all the code checks. - Git is used for version control, if it is not initialized,
make devwill rungit init. - Python's venv + pip manage the virtual environments and dependencies.
The environment can be loaded using the
. scripts/shell.shcommand. - The .env file holds environment variables, and is loaded using python-dotenv.
- pre-commit runs pre-commit-hooks for validating each commit.
- pytest is used for running the unit tests. It is set up to fail fast and run the previously failed tests first. pytest-cov generates the test coverage report.
- The code is auto-formatted using black and isort.
- flake8 is used as code linter, but it ignores the stylistic issues that are fixed by Black.
- mypy is used for static code analysis and type checking.
- Each of the steps is configured to fail fast in case of any error.
-
Click the "Use this template" button in GitHub to create a new repository
OR
copy all the files to your local machine, to the directory where you want to start a new project.
-
Run
make devto setup the dev environment. If you want to use a specific version of python, usemake dev PYTHON=python3.8, wherePYTHON=should point to the name of the Python executable or path leading to it.
Additionally:
- Any time you edit
requirements.txtorrequirements-dev.txt, runmake updateto update all the dependencies. - To test the code run
makeormake allchecksis you want to be more specific. For running individually the black and isort, linter, mypy, or unit tests, usemake stylecheck,make lint,make typecheck,make testrespectively. If you want to manually fix code formatting, runmake stylefix.make coveragewould generate the test coverage report. To manually run the pre-commit hooks, runmake precommit.