Python template that includes all the basics for your new shiny project.
- Open a new repository while using this template. This repository is marked as a template repository. Github offers you the convenient possibility to open a new repository from a such a template repository. See here for details.
- Clone your new repository
- Rename the
python-project
package to your project name (this is where your source code should go). - Install the dependencies (preferably within a fresh virtual environment)
- Run
pre-commit install
- Enjoy!
To spare you the pain of manually taking care of formatting your code and establish some consistency (remember "äußere Ordnung führt zu innerer Ordnung") it includes Black for automated formatting.
Execute black .
in the terminal at the project's root directory to format your code.
To make sure your code actually does what you think it does!
The template includes pytest for that purpose.
Include the tests in the tests
directory. Running pytest
in the terminal at the project's root directory executes all tests and hopefully replaces hoping that your code works by knowing (at least so far as your actual test all relevant cases and boundary conditions).
To give you a slap on the wrist if you did not apply the formatter or your tests don't pass there is a Github Actions workflow at .github/workflows/simple-ci.yml
.
After pushing to the remote repository it checks out your code, installs all the dependencies then runs flake8
for any code style issues and black --check
to check the formatting.
Depending on how that went you will see yourself either confronted with a friendly green tick or rather unfriendly red cross at the code window in github (or the Actions
section of the github repository.)
To reduce slaps on the wrist there is pre-commit having your back.
It installs pre-commit hooks that black
and flake8
before the CI gets a chance to complain.
The types of git hooks are configured in .pre-commit-config.yaml
.
To install the hooks run pre-commit install
once in the terminal at the project's root directory.
To keep the dust off your dependencies Dependabot checks for new versions once a day (according to current cofigurations) and opens Pull-Requests in case it finds any newer versions.
The configuration can be changed at .github/dependabot.yml
Keep in mind that dependency updates can break your code.
You safeguard yourself against this by making sure you have all your code tested and the dependency pull request does not break any of them.
We are happy to learn about additional tools for easing the developer workflow. Feel free to open an issue or pull-request to make suggestions.