simple-di
simple dependency injection library
What it is and what it does
simple-di is a dependency injection framework for Python that uses type annotations to wire dependencies into functions and methods. It provides a container pattern where you define providers (Static, Factory, SingletonFactory, Configuration) that compute or store values, then use the @inject decorator to automatically pass those values into function arguments. The library supports runtime value overrides via set() and reset() methods, making it useful for testing and configuration management.
The package depends only on dataclasses and types-dataclasses, keeping the runtime footprint minimal. It supports Python 3.6 through 3.9 and is actively maintained, though it remains in pre-alpha status. The strict typing support means you get IDE autocomplete and type checking for injected dependencies.
Use it for:
- Wiring configuration values (database URLs, API keys, feature flags) into application functions without passing them as arguments
- Testing by temporarily overriding provider values without modifying production code
- Building modular applications where components declare their dependencies declaratively rather than instantiating them directly
- Creating factory-based object graphs where computed dependencies depend on other dependencies in a defined order
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
A strictly typed dependency injection library that lets you define and inject dependencies into functions using type annotations and a container pattern.
Yes, if you need lightweight typed dependency injection for Python 3.6+. The low install friction, permissive license, and active maintenance make it safe to adopt. However, be aware it remains pre-alpha—verify that its feature set and stability match your project's needs before relying on it in production.
Install
simple-di on PyPI
pip
pip install simple-diuv
uv add simple-dipoetry
poetry add simple-diInstalling simple-di
Before you install
Low friction install with no compiled dependencies. The package is actively maintained as of July 2026, though it has been in pre-alpha status since its first release in June 2021.
License in practice
Licensed under Apache License 2.0 (permissive), so you can use it freely in commercial and open-source projects with minimal restrictions.
Quickstart
pip install simple-di
from simple_di import inject, Provide, Provider, container
from simple_di.providers import Static, Factory
@container
class Options(container):
cpu: Provider[int] = Static(2)
worker: Provider[int] = Factory(lambda c: 2 * c + 1, c=cpu)
@inject
def process(worker: int = Provide[Options.worker]):
return worker
print(process()) # 5
Verify before relying
- Whether the pre-alpha status reflects incomplete features or simply conservative versioning
- Production readiness and stability guarantees given the 0.1.5 version number
Package facts
| License | Apache License 2.0 (permissive) |
| Python support | supports the current Python release (>=3.6.1) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — dataclasses, types-dataclasses |
| Maintenance | actively maintained — 1,634 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 171,836/month — #10,352 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: simple_di-0.1.5-py3-none-any.whl
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
in-n-outLightweight dependency injection framework…
permissive · top 15,000 on PyPI
kinkKink is a lightweight dependency injection…
permissive · top 15,000 on PyPI
fast-dependsFastDepends provides a standalone dependency…
permissive · top 5,000 on PyPI
rodiRodi is a dependency injection container for…
permissive · top 15,000 on PyPI
slackA dependency injection container that registers…
permissive · top 15,000 on PyPI
allukaAlluka is a type-based dependency injection…
permissive · top 15,000 on PyPI
injectorInjector is a Python dependency injection…
permissive · top 5,000 on PyPI
injectProvides a lightweight dependency injection…
permissive · top 5,000 on PyPI
punqPunq is a dependency injection container for…
unclear · top 15,000 on PyPI