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 ★3407 - 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 ★4028 - Dependency injection framework for Python. [🐍, BSD 3-Clause "New" or "Revised" License].
- returns ★3667 - Make your functions return something meaningful, typed, and safe!. [🐍, BSD 2-Clause "Simplified" License].
- Injector ★1332 - Python dependency injection framework, inspired by Guice. [🐍, BSD 3-Clause "New" or "Revised" License].
- Inject ★705 - Python dependency injection. [🐍, Apache License 2.0].
- Dishka ★438 - Cute DI framework with agreeable API and everything you need. [🐍, Apache License 2.0].
- Kink ★414 - Dependency injection container made for Python. [🐍, MIT License].
- FastDepends ★322 - FastAPI Dependency Injection system extracted from FastAPI and cleared of all HTTP logic. [🐍, MIT License].
- Punq ★316 - An IoC container for Python 3.6+. [🐍, MIT License].
- svcs ★314 - A Flexible Service Locator for Python. [🐍, MIT License].
- di ★304 - Pythonic dependency injection. [🐍, MIT License].
- Lagom ★246: Type based auto-wiring dependency injection with support for async and threading. [🐍, MIT License].
- Rodi ★180 - Implementation of dependency injection for Python 3. [🐍, MIT License].
- That Depends ★163 - simple DI-framework, inspired by python-dependency-injector, but without wiring [🐍, MIT License].
- injectable ★114 - Python Dependency Injection for Humans™. [🐍, MIT License].
- Wireup ★104 - Concise, Powerful, and Type-Safe Python Dependency Injection Library. [🐍, MIT License].
- Opyoid ★67 - Dependency injection library for Python. [🐍, MIT License].
- Picodi ★24 - A DI library inspired by FastAPI. It integrates well with FastAPI but can also be used independently. [🐍, MIT License].
- andi ★22 - 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].
- ididi ★16 - Genius simplicity, unmathced power, dependency injection in a single line of code. [🐍, MIT License]
- Modern DI ★15 - powerful DI-framework with scopes and IoC-container [🐍, MIT License].
- Clean IoC ★9 - A simple unintrusive dependency injection library for python with strong support for generics [🐍, MIT License].
- injection ★9 - replacement for python-dependency-injector that works with Python 3.8-3.12 and works with FastAPI, DRF, Flask and Litestar [🐍, 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 ★89 - 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 ★279 - Adds Injector support to Flask. [🐍, BSD 3-Clause "New" or "Revised" License].
See also above.