injector
Injector - Python dependency injection framework, inspired by Guice
What it is and what it does
Injector is a dependency injection framework that automatically wires dependencies into your classes and functions, inspired by Guice but designed for Python idioms. Rather than manually passing dependencies or relying on global state, you declare what your code needs via type hints, and Injector constructs and provides those dependencies for you. It supports scoping like singletons, custom providers, and modular configuration through Module classes, making it particularly useful for decoupling configuration from business logic and reducing boilerplate in larger applications.
The framework emphasizes simplicity and non-intrusiveness: your classes remain standard Python classes that can be instantiated manually if needed, and the framework avoids global state by requiring explicit Injector instances. It cooperates with static type checkers, allowing type-safe dependency retrieval. The main runtime dependency is typing_extensions, making installation straightforward with low friction.
Use it for:
- Decoupling configuration and database initialization in web applications or services
- Automatically providing shared resources like database connections to multiple handlers
- Building testable code by swapping real implementations for mocks through different Injector configurations
- Organizing large codebases into modules with clear dependency boundaries and reusable components
- Reducing constructor boilerplate when many classes need the same set of dependencies
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Injector is a Python dependency injection framework that automatically resolves and provides dependencies to your code, reducing boilerplate in larger applications through constructor injection and modular configuration.
Yes. Injector is actively maintained, has no known vulnerabilities, low install friction, and a permissive license. It's worth installing if you're building a larger application where dependency injection reduces boilerplate and improves testability; for small scripts or projects where manual dependency passing is simpler, it adds unnecessary overhead.
Install
injector on PyPI
pip
pip install injectoruv
uv add injectorpoetry
poetry add injectorInstalling injector
Before you install
Low friction install with a single runtime dependency on typing_extensions. The package is actively maintained with a recent release and 1536 repository stars, indicating stable, ongoing support.
License in practice
BSD permissive license allows use in most projects, including commercial ones, with minimal restrictions beyond attribution.
Quickstart
pip install injector
from injector import Injector, inject
class Inner:
def __init__(self):
self.forty_two = 42
class Outer:
@inject
def __init__(self, inner: Inner):
self.inner = inner
injector = Injector()
outer = injector.get(Outer)
print(outer.inner.forty_two)
Verify before relying
- Whether the package supports Python 3.8+ as stated in the description excerpt (requires_python field is unspecified in metadata)
- Whether PyPy 3 support mentioned in the description is actively tested and maintained
Package facts
| License | BSD (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — typing_extensions |
| Maintenance | actively maintained — 217 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 4,042,933/month — #2,391 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: injector-0.24.0-py3-none-any.whl
Keywords: Dependency Injection, DI, Dependency Injection framework, Inversion of Control, IoC, Inversion of Control container
Tags
More Application Frameworks packages
FastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
textualTextual is a Python framework for building…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
mcpBuild and connect to Model Context Protocol…
permissive · top 1,000 on PyPI
WerkzeugWerkzeug is a WSGI utility library providing…
permissive · top 1,000 on PyPI
dependency-injectorDependency Injector is a dependency injection…
permissive · top 5,000 on PyPI
fastapi-injectorIntegrates the injector dependency-injection…
permissive · top 15,000 on PyPI
Flask-InjectorIntegrates dependency injection into Flask…
permissive · top 15,000 on PyPI
injectProvides a lightweight dependency injection…
permissive · top 5,000 on PyPI
kinkKink is a lightweight dependency injection…
permissive · top 15,000 on PyPI
pinjectPinject is a dependency injection library that…
permissive · top 15,000 on PyPI
dependenciesImplements constructor injection for dependency…
permissive · top 15,000 on PyPI
slackA dependency injection container that registers…
permissive · top 15,000 on PyPI
in-n-outLightweight dependency injection framework…
permissive · top 15,000 on PyPI
simple-diA strictly typed dependency injection library…
permissive · top 15,000 on PyPI