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).
The tools below are the standard tools we’re using to keep project quality and developer efficiency high at Abilian.
- Git + GitHub
- Branching model: use short-lived feature branches.
Project management (including dependencies)¶
- 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¶
- Flake8 + additional plugins (Bandit…)
- 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.
- GitHub Workflow
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¶
- https://pypi.org/project/q/ (there are better, newer alternatives but I don’t remember them)
- We used to use Fabric but we’re now swicthing to PaaS deployment (using the 12 factor principles). This is a WIP.
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.
Use cookiecutter templates to set up new projects.
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).
Use Attrs and favor immutability when possible:
Things to know about subclassing:
- The Best of the Best Practices (BOBP) Guide for Python (partly obsolete).
- Our own Abilian Developer Guide (unfortunately currently partly obsolete too).
- Google’s Python Style Guide
- Python Project Setup