Contributing

Coordinate First

Before you create a pull request, please create a new issue first or check in on gitter to coordinate.

It might be that we are already working on the same or similar feature, but we haven’t made our work visible yet.

Create a Development Environment

We usually develop in a virtual environment. To create one, change to the root directory of the repository and invoke:

python -m venv venv

You need to activate it. On nix (Linux, Mac, *etc.):

source venv/bin/activate

and on Windows:

venv\Scripts\activate

Install Development Dependencies

Once you activated the virtual environment, you can install the development dependencies using pip:

pip3 install --editable .[dev]

The –editable option is necessary so that all the changes made to the repository are automatically reflected in the virtual environment (see also this StackOverflow question).

Pre-commit Checks

We provide a battery of pre-commit checks to make the code uniform and consistent across the code base.

We use black to format the code and use the default maximum line length of 88 characters.

The docstrings need to conform to PEP 257. We use Sphinx docstring format to mark special fields (such as function arguments, return values etc.). Please annotate your function with type annotations instead of writing the types in the docstring.

To run all pre-commit checks, run from the root directory:

python precommit.py

You can automatically re-format the code with:

python precommit.py --overwrite

Here is the full manual of the pre-commit script:

usage: precommit.py [-h] [--overwrite] [--noparallel] [--select  [...]]
                    [--skip  [...]]

Run pre-commit checks on the repository.

options:
  -h, --help        show this help message and exit
  --overwrite       Try to automatically fix the offending files (e.g., by re-
                    formatting).
  --noparallel      If set, disable parallelization test options.
  --select  [ ...]  If set, only the selected steps are executed. This is
                    practical if some of the steps failed and you want to fix
                    them in isolation. The steps are given as a space-
                    separated list of: black flake8 isort pydocstyle mypy
                    doctest check-init-and-setup-coincide check-help-in-doc
                    test
  --skip  [ ...]    If set, skips the specified steps. This is practical if
                    some of the steps passed and you want to fix the remainder
                    in isolation. The steps are given as a space-separated
                    list of: black flake8 isort pydocstyle mypy doctest check-
                    init-and-setup-coincide check-help-in-doc test

The pre-commit script also runs as part of our continuous integration pipeline.

Write Commit Message

We follow Chris Beams’ guidelines on commit messages:

  1. Separate subject from body with a blank line

  2. Limit the subject line to 50 characters

  3. Capitalize the subject line

  4. Do not end the subject line with a period

  5. Use the imperative mood in the subject line

  6. Wrap the body at 72 characters

  7. Use the body to explain what and why vs. how

Contributor List

In order of inital commit. Many thanks!