Awesome Dependency Injection in Python
A curated list of awesome things related to dependency inversion / dependency injection in Python.
Talks / slides
- Python Dependency Injection (PDF) (Alex Martelli, 2008).
- Fang: Pythonic dependency injection (video) (Nathan Craike, 2015).
Articles / blog posts
- Enforcing Single Responsibility Principle in Python (Nikita Sobolev / Никита Соболев, 2019)
- Pythonic Dependency Injection: A Practical Guide (Sune Andreas Dybro Debel, 2018)
- Elegant Flask API Development Part 1 (mostly covers Flask-Injector).
- "(pytest) Fixtures: a prime example of dependency injection"
- Tests and comparison of Python dependency injection libraries ★3
- Typed Functional Dependency Injection in Python
Books
- Pythonic Application Architecture Patterns for Managing Complexity ★2866, see specially this chapter: Dependency Injection (And Mocks)
Software
DI Frameworks
- returns ★2587: "Make your functions return something meaningful, typed, and safe!". Part of the dry-python ecosystem.
- python-dependency-injector ★2681: "Dependency injection microframework for Python"
- Injector ★895: "Python dependency injection framework, inspired by Guice".
- Inject ★545: Python dependency injection
- Dependencies ★330: "Constructor injection designed with OOP in mind."
- Punq ★202: "An IoC container for Python 3.6+."
- di ★148: Pythonic dependency injection. Used by (and developped for) the Xpresso Web framework.
- injectable ★90: "Injectable: Dependency Injection for Humans™"
- Antidote ★79: "Dependency injection for Python"
- Rodi ★73: Dependency injection for Python 3 (used by, and developped for, the BlackSheep web framework).
- Lagom ★30: Type based auto-wiring dependency injection with support for async and threading.
Archived or unmaintained
- Serum ★84: "Dependency injection framework for Python 3.6" (unmaintained)
- Aiodine ★55: "Async-first Python dependency injection library" (unmaintained)
- Wiring ★28: Architectural foundation for Python applications. (Unmaintained).
Integration with web frameworks
- Flask-Injector ★247: Adds Injector support to Flask.
- Pyramid-Wiring ★0: integration of Wiring and Pyramid (unmaintained).