Skip to content

Latest commit

 

History

History
148 lines (99 loc) · 5.67 KB

CONTRIBUTING.md

File metadata and controls

148 lines (99 loc) · 5.67 KB

Contributing

Quick start

Assuming you have pyenv and Poetry, clone the repository and run:

# Use Python 3.9.9 in the project
pyenv local 3.9.9

# Tell Poetry to use pyenv
poetry env use $(pyenv which python)

# Install dependencies
poetry install

# Activate the virtual environment
poetry shell

# Install pre-commit hooks
pre-commit install

Installing things

We've tried to keep necessary things as simplistic as possible. However, we need to install some things.

Poetry

This project uses Poetry for creating virtual environments and managing Python packages. This should be installed globally and can be done by running:

curl -sSL https://install.python-poetry.org | python3 -

You can verify it's installed and accessible by running poetry --version.

Once you've got Poetry installed, we think it's best to install Python dependencies into a .venv/ folder within the cloned repo. Tell Poetry to handle this for you:

poetry config virtualenvs.in-project true

For more on how to manage, add, remove, and update dependencies, see the official Poetry documentation.

Managing Python versions...

There are two ways of managing your Python environments. We recommend pyenv, but we have also included instructions for Anaconda.

...with pyenv

Install pyenv following the instructions within the official repo for your system. Remember to do step 2!

You can verify it's installed with pyenv --version.

  1. Install the Python version you want with pyenv install 3.9.9
  2. Go to the cloned repo
  3. Assign the specific Python version to the project by running pyenv local 3.9.9

If you want a different version of Python, just change the version in the steps.

...with Anaconda

Install Anaconda using the instructions on the official website.

Then create an environment for your project by running:

conda create -n PROJECT_NAME python=3.9
conda activate PROJECT_NAME

Developer tooling

Code style

To ensure all code is standardized, we use black, along with other automatic formatters. To enforce a consistent coding style, we use Flake8 with the wemake-python-styleguide. To verify and enforce type annotations, we use mypy. Common tasks can be called using Poe the Poet.

Task runner

Poe the Poet is a task runner that works well with Poetry. To see what tasks exist, run poe in your terminal. If you want to add more tasks, check the documentation and what already exists.

If you have issues getting poe to work, make sure that you are already within the activated shell (by running poetry shell).

Formatting

If you want to automatically format on every commit, you can use pre-commit. As mentioned above, run pre-commit install and it will install the hooks.

To manually format all files, run

poe format

Linting

If you want to check the linting rules on the codebase, run

poe lint

Type checking

If you want to check types on the codebase, run

poe typecheck

Working with branches

We've settled on a middle ground when it comes to developing: keep the main branch clean.

Within branches, you can do whatever you want to do, but you should never push anything directly to the main branch.

For every PR, an automated set of linters and formatters will check your code to see whether it follows the set rules. If it fails, do not merge with the main branch.