Python Guidelines

These Python Guidelines (style guide) empower the community to focus on the intent of the code and work together with a minimum of friction.

Code Formatting

Overview

All Python code must be formatted using Black, the uncompromising Python code formatter. Each project should contain a pyproject.toml configuration file that limits line length to 79 characters.

Examples

Style and Quality

Overview

All Python code must be checked using flake8, a python tool that glues together pep8, pyflakes, mccabe, and third-party plugins to check the style and quality of some python code.

Conflicts with Black

Where flake8 conflicts with Black, the flake8 check should be skipped. For example, there are instances where black formats code that generates flake8 warning for Whitespace before ':' (E203).

Examples

Development Environment

Overview

Please work to minimize the number of development related technologies. This helps minimize the overhead of contributing to multiple projects. Most of our projects use either Pipenv, the Python Development Workflow for Humans, or docker-compose, a tool for defining and running multi-container Docker applications.

Examples

Additional Guidance

Thankfully, Black removes a lot of style work and worry. Where there is room for developer discretion, the following guides are excellent resources: