A curated list of awesome things related to dependency inversion / dependency injection in Python.
- Python Dependency Injection (PDF) (Alex Martelli, 2008).
- Fang: Pythonic dependency injection (video) (Nathan Craike, 2015).
- Loose Coupling & Dependency Injection the EASY Way! (Hynek Schlawack, 2024)
- Dependency Inversion: Write BETTER PYTHON CODE Part 2 (ArjanCodes, 2021)
- Dependency INVERSION vs Dependency INJECTION in Python (ArjanCodes, 2021)
- 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 - Tests and comparison of Python dependency injection libraries. [π, Unknown license].
- Typed Functional Dependency Injection in Python
- DI patterns (Abilian, 2024)
- DI anti-patterns (Abilian, 2024)
- Pythonic Application Architecture Patterns for Managing Complexity β 3653 - A Book about Pythonic Application Architecture Patterns for Managing Complexity. Cosmos is the Opposite of Chaos you see. O'R. wouldn't actually let us call it "Cosmic Python" tho. [π, Other license].
- python-dependency-injector β 4690 - Dependency injection framework for Python. [π, BSD 3-Clause "New" or "Revised" License].
- returns β 4153 - Make your functions return something meaningful, typed, and safe!. [π, BSD 2-Clause "Simplified" License].
- Injector β 1474 - Python dependency injection framework, inspired by Guice. [π, BSD 3-Clause "New" or "Revised" License].
- Dishka β 930 - Cute DI framework with agreeable API and everything you need. [π, Apache License 2.0].
- Inject β 747 - Python dependency injection. [π, Apache License 2.0].
- FastDepends β 470 - FastAPI Dependency Injection system extracted from FastAPI and cleared of all HTTP logic. [π, MIT License].
- Kink β 435 - Dependency injection container made for Python. [π, MIT License].
- Punq β 405 - An IoC container for Python 3.6+. [π, MIT License].
- svcs β 391 - A Flexible Service Locator for Python. [π, MIT License].
- di β 329 - Pythonic dependency injection. [π, MIT License].
- Lagom β 246: Type based auto-wiring dependency injection with support for async and threading. [π, MIT License].
- That Depends β 234 - simple DI-framework, inspired by python-dependency-injector, but without wiring [π, MIT License].
- Wireup β 232 - Concise, Powerful, and Type-Safe Python Dependency Injection Library. [π, MIT License].
- Rodi β 230 - Implementation of dependency injection for Python 3. [π, MIT License].
- injectable β 119 - Python Dependency Injection for Humansβ’. [π, MIT License].
- python-injection β 107 - Dead-simple dependency injection framework for Python. [π, MIT License].
- Opyoid β 75 - Dependency injection library for Python. [π, MIT License].
- Modern DI β 43 - powerful DI-framework with scopes and IoC-container [π, MIT License].
- Picodi β 27 - A DI library inspired by FastAPI. It integrates well with FastAPI but can also be used independently. [π, MIT License].
- andi β 24 - Library for annotation-based dependency injection. [π, BSD 3-Clause "New" or "Revised" License].
- Fresh Bakery β 21 - Bake dependency injections asynchronously and stupidly simple. [π, MIT License].
- engin β 20 - a dependency injection powered application framework, inspired by Uber's fx framework. [π, MIT License].
- ididi β 18 - Genius simplicity, unmathced power, dependency injection in a single line of code. [π, MIT License]
- injection β 17 - replacement for python-dependency-injector that works with Python 3.8-3.12 and works with FastAPI, DRF, Flask and Litestar [π, MIT License].
- Clean IoC β 11 - A simple unintrusive dependency injection library for python with strong support for generics [π, MIT License].
Several modern Python web frameworks include DI components, including:
- FastAPI -> Dependencies - First Steps.
- Litestar -> Dependency Injection.
- Sanic -> Dependency Injection.
- Xpresso -> di (see above)
- Blacksheep -> Rodi (see above)
- Aiodine (dead, see below) was the DI framework for the Bocadillo project (also dead)
- Antidote β 88 - Dependency injection for Python. [π, MIT License].
- Serum β 86 - Dependency injection framework for Python 3.6. [π, MIT License].
- Aiodine β 53 - π§ͺ Async-first Python dependency injection library. [π, MIT License].
- Wiring β 26 - Architectural foundation for Python applications. [π, Apache License 2.0].
- Flask-Injector β 282 - Adds Injector support to Flask. [π, BSD 3-Clause "New" or "Revised" License].
See also above.