Sometimes learning all the things feels quite overwhelming. This is a streamlined (minimalist) guide to software development with Python. As such it must be opinionated. One tool is chosen over another, not necessarily because it is better but because we need a path forward.
Linux
For Linux and Mac machines this is pretty easy. If you are using a Windows machine, you’ll need to install Windows Subsystem for Linux (WSL). For our purposes we’ll be using Ubuntu.
Python Version Management
A language version manager provides a simple way to install and use multiple versions of a language. Node.js has nvm, Ruby has rvm, Python has pyenv.
Python Environment and Dependencies Management
We’ll be using Poetry (the other big player is pipenv).
Code Formatting
Black is an opinionated and popular code formatter.
Static Typing
Call me old-fashioned (or is it new-fashioned these days) but I prefer explicitly declaring my variables types over them being dynamically deduced. To this end we’ll use mypy.
Testing
We’ll use pytest.
- Mocking – Built into pytest.
- Use pytest-mock
- Use pytest monkeypatch
- Code Coverage
- Use pytest-cov (Coverage.py under the hood)
Bibliography
- Jan Giacomelli. The Complete Python Development Guide. testdriven.
- Jacob Kaplan-Moss. My Python Development Environment, 2020 Edition. jacobian, 11/2019.
- Uses pipx, may consider adding this in the future.