Python Software Project Components

Get Started. It's Free
or sign up with your email address
Python Software Project Components by Mind Map: Python Software Project Components

1. User interface

1.1. CLI

1.1.1. Use click

1.2. REST API

1.2.1. Use requests or httpx

2. Testing

2.1. Unit tests

2.1.1. Use pytest

2.1.2. Ideal unit tests should be

2.1.2.1. Fast

2.1.2.2. Isolated

2.1.2.3. Repeatable

2.1.3. Write tests before you write code, and make them fail. Then write code, then make the tests pass.

2.1.4. Allow you to refactor code

2.2. Code coverage

2.2.1. Use coverage.py

2.2.1.1. Integrate with pytest: pytest-cov

2.2.2. Use Codecov or coveralls for coverage reporting

2.3. Running tests automatically with relevant Python environments

2.3.1. Use nox

2.4. Mocking objects

2.4.1. Use pytest-mock

2.4.2. Or fixtures

2.4.3. Or fakes (fake implementations)

2.4.3.1. e.g. in-memory DB instead of real DB

2.4.4. Can check if obj is called

2.4.5. Can check called arguments

2.4.6. Can raise exceptions via side_effects

2.5. End-to-end tests

2.5.1. Use pytest, but with a marker

2.5.2. Can skip while invoking pytest

3. Language and environment

3.1. Python version

3.1.1. Use pyenv

3.2. Library dependencies

3.2.1. Use poetry

3.2.2. Poetry can also separate dependencies for dev, test and prod

3.2.3. Poetry can also upload package to PyPI

4. Linting

4.1. Use flake8

4.2. flake8-import-order checks imports

4.3. flake8-bugbear finds bugs and design problems

5. Security

5.1. flake8-bandit finds security issues

5.2. "Safety" package checks dependencies for known security issues

6. Code formatting

6.1. Use black

7. Data validation

7.1. Use dataclasses from standard library

7.2. Use Marshmallow to define and validate schemas

7.2.1. A package "Desert" can generate schemas based on dataclasses

8. Static and runtime type checking

8.1. Static: Use mypy

8.1.1. De-facto; core Python committers are involved in it

8.2. Runtime: Use Typeguard

8.3. Use flake8-annotations to track untyped code

9. Documentation

9.1. Use docstrings

9.1.1. Use Google docstring style

9.2. flake8-docstrings can validate docstrings

9.3. Use darglint to ensure docstring matches prototype

9.4. Use xdoctest to run examples within docstrings

9.5. Use Sphinx to create project documentation

9.5.1. Markup is with reStructuredText

9.5.2. Comes with "autodoc" for API documentation

10. Version Control

10.1. Use git

11. CI/CD

11.1. Use GitHub actions for CI

11.2. Use Release Drafter to automatically add PRs for release notes as they merge

11.3. Use TestPyPI to test distribution

11.4. Use ReadTheDocs to host your documentation

12. Quick Reference for a Python project