Contributing

This contributing guide is trying to avoid common pitfalls, but the project development environment is quite common. If it’s not your first rodeo, here’s a TL;DR

TL;DR

(The following is not meant to be executed as a script)

$ # Install requirements
$ pip install -r requirements.txt

$ # Launch tests
$ tox -e py39-tests

$ # Use CLI
$ foobartory -v

Instructions for contribution

Set up your development environment

If you plan to launch the project locally, install the package itself with development dependencies in a virtual environment:

$ python3 -m venv venv
$ source venv/bin/activate

You can check that your Python environment is properly activated:

(venv) $ which python
/path/to/current/folder/venv/bin/python

Install local dependencies:

(venv) $ pip install -r requirements.txt

Run the project automated tests

(venv) $ tox -e py39-tests

Or

(venv) $ tox  # Run all the checks for all the interpreters

If you’re not familiar with Pytest, do yourself a treat and look into this fabulous tool.

If you don’t know Tox, have a look at their documentation, it’s a very nice tool too.

To look at coverage in the browser after launching the tests, use:

$ python -m webbrowser htmlcov/index.html

Keep your code clean

Before committing:

$ tox -e format

You can also install a pre-commit hook which makes sure that all your commits are created clean:

cat > .git/hooks/pre-commit <<EOF
#!/bin/bash -e
exec ./pre-commit-hook
EOF
chmod +x .git/hooks/pre-commit

If tox is installed inside your virtualenv, you may want to activate the virtualenv in .git/hooks/pre-commit:

#!/bin/bash -e
source /path/to/venv/bin/activate
exec ./pre-commit-hook

This will keep you from creating a commit if there’s a linting problem.

Build the documentation

$ tox -e docs
$ python -m webbrowser docs/_build/html/index.html