Code Style

Linting and formatting

We orientate our code style on the Google Python Style Guide and PEP 8.

To enforce this rules we use pre-commit. To run them locally use:

pre-commit run -a

See pre-commit for more information.

This will lint your code with flake8 and automatically try to fix some issues with black.

We also configured a few more packages to run with pre-commit:

  • isort to sort imports

  • mypy for type hints checking

  • bandit for security checking

See the .pre-commit-config.yaml file for more.

Type hints

As Python itself is a dynamically typed language, we use their typing support to add type hints to our code. This helps to understand the code and to find bugs.

To enforce type hints we use mypy. Its configured to be strict and to fail on any type hint error. If you run pre-commit you will also run mypy.

Security

We use bandit to find common security issues in our code. If you run pre-commit you will also run bandit.