Contributing

We love contributions! We’ve compiled this documentation to help you understand our contributing guidelines. Please also read our CODE_OF_CONDUCT.md.

[If you still have questions, please contact us][email] and we’d be happy to help!

Getting started

To start contributing, open your terminal and install the package and pre-commit hooks using:

pip install -e .[dev]
pre-commit install

or use the make command:

make install_dev

The pre-commit hooks are a security feature to ensure, for example, no secrets, large data files, or Jupyter notebook outputs are accidentally committed into the repository. For more information and common use cases, please refer to a hook’s documentation such as detect-secrets or nbstripout.

Code conventions

We mainly follow PEP8 standards in our code conventions, and use ruff pre-commit hook for linting and formatting.

We use MyPy to enforce type-checking to ensure the rigidity of our framework and bandit for vulnerability checking as a point of best practice. These are also pre-commit hooks in the project.

Git and GitHub

We use Git to version control the source code. Please read the Quality assurance of code for analysis and research for details on Git best practice. This includes how to write good commit messages, how to branch appropriately and solve merge conflicts.

The .gitignore used in this repository was created with generic exclusions from gitignore.io.

Pull requests into main require at least one approved review.

Markdown

Local links can be written as normal, but external links should be referenced at the bottom of the Markdown file for clarity. For example:

Use a local link to reference the README.md file, but an external link for GOV.UK.

We also try to wrap Markdown to a line length of 88 characters, but this is not strictly enforced in all cases, for example with long hyperlinks.

Testing

Tests are written using the pytest framework, with its configuration in the pyproject.toml file. Note, only tests in the tests folder are run. To run the tests, enter the following command in your terminal:

pytest

Code coverage

Code coverage of Python scripts is measured using the coverage Python package; its configuration can be found in pyproject.toml. Note coverage only extends to Python scripts in the onsrap folder.

To run code coverage, and view it as an HTML report, enter the following command in your terminal:

coverage run -m pytest
coverage html

or use the make command:

make coverage_html

The HTML report can be accessed at htmlcov/index.html.

Documentation

Documentation is stored in the docs folder unless it’s more appropriate to store it elsewhere, like this contributing guidance. We write our documentation in MyST Markdown for use in Sphinx, to make a searchable wesite. Public sector websites must be accessible by law, and GOV.UK has further information on these requirements.

To create the website locally, run the following command in your terminal at the top-level of this project:

make docs

This should create an HTML version of your documentation accessible from docs/_build/index.html.