Skip to content

Python One Pager

About this doc

This is a shorter, and hopefully more up to date, version of the Abilian Developer Guide (unfortunately currently partly obsolete).

Project organisation

Tooling

The tools below are the standard tools we’re using to keep project quality and developer efficiency high at Abilian.

Source control

  • Git + GitHub
  • Branching model: use short-lived feature branches.

Project management (including dependencies)

  • Poetry
  • Make

Code formatting

  • Black (format Python code - use default options)
  • Isort (sort imports - use the “black” profile)
  • DocFormatter (format docstrings)
  • Pyupgrade / flynt (upgrade to take advantage of newer Python features)

Linting / static analysis

  • Mypy
  • Flake8 + additional plugins (Bandit…)
  • pre-commit

TDD

  • Pytest
  • Tox
  • Coverage.py
  • Hypothesis (not really using it, currently - we should use it more)

We don’t recommend using the unittest package from the standard library, as its class-based design can lead to hard to understand test hierarchies.

More: Testing

CI

  • GitHub Workflow
  • CircleCI

Note: the main CI script, for Python projects, is always the Tox file (tox.ini). The GitHub Workflow or CircleCI config leverages it using proper tox plugins.

Debugging / profiling

Deployment

  • We used to use Fabric but we’re now swicthing to PaaS deployment (using the 12 factor principles). This is a WIP.

Documentation

Documentation starts with a good README (see: https://tom.preston-werner.com/2010/08/23/readme-driven-development.html).

Additionally, we use Sphinx but MkDocs can also be used. Portray could be useful.

Project templates

Use cookiecutter templates to set up new projects.

Even better, use Cruft because it can update boilerplate after the initial project inception. (Narative here)

We have a project template here: https://github.com/abilian/cookiecutter-abilian-python (it needs to be updated regularly to keep up with best practices).

General principles

Use Attrs and favor immutability when possible:
- https://glyph.twistedmatrix.com/2016/08/attrs.html
- https://threeofwands.com/why-i-use-attrs-instead-of-pydantic/

Things to know about subclassing:
- https://hynek.me/articles/python-subclassing-redux/

(TBC)

Other resources

Similar docs

Great online Python docs / information sources

Great Python books

Back to top