Tox is set to facilitate testing and managing environments during development and ensure that the same commands can easily be run locally and in CI.
Install it with:
pip install -r requirements_dev.txt
You can set up certain environment or run certain command by calling tox
.
Calling tox
with no extra argument will simply run
all the default commands defined in the tox configuration (tox.ini
).
In our case it will run all our formatting tools by using pre-commit
Use tox list
to view all environment descriptions.
Use tox run
to run a specific environment.
Example
tox run -e lint
Some environments allow passing extra argument:
# only run black
tox run -e lint -- black
We use:
- black for python code formatting
- isort for sorting of python imports
- flake8 with flake8-bugbear for linting
- codespell for spellchecking
We use pre-commit to run a set of linters and autoformatters on the codebase and ensure code style compliance at commit time.
You can easily run it by relying on tox and type:
tox
Pre-commit will then run all those hooks on the files you have staged for commit. Note that while several hooks will auto-fix files when they have failed the checks (meaning you just need to stage the edited files), for others, if the hooks fail you may have to edit some files manually before staging them again.
- official documentation: https://pre-commit.com/
If you need to add new dependencies, add them to the requirements.in
file
and then run
tox run -e update_dependencies
to update the content of the requirements.txt
.