Template git repository for creating Python packages. Includes the a sample project structure, linting, type checks, unit tests, formatting, and continuous integration.
Clone the repository.
git clone https://github.com/f4str/python-package-templateChange directories into the cloned repository.
cd python-package-templateInstall Python and create a virtual environment.
python3 -m venv venv
source venv/bin/activateInstall the dev dependencies using pip.
pip install -e .[dev]The tox library is used to run all tests and code formatting. This is automatically installed with the dev requirements. The available options are as follows.
-
Run linting checks using
flake8.tox -e lint
-
Run type checks using
mypy.tox -e type -
Run unit tests
pytest.tox -e test -
Run all three of the tests above.
tox
-
Format the code using
blackandisortto comply with linting conventions.tox -e format
Upon pull request, merge, or push to the master branch, the three tests with tox will be run using GitHub Actions. The workflow will fail if any of the tests fail. See .github/workflows/python-package.yml for more information on how the CI works.