skillfed

simple-di

simple dependency injection library

simple-di v0.1.5 171.8K downloads/30d#10,352 on PyPI21
Permissive license Apache License 2.0 Active released

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-di

uv

uv add simple-di

poetry

poetry add simple-di

Installing 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

Development Status :: 2 - Pre-AlphaOperating System :: OS IndependentProgramming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPython

Tags

dependency injectiontyped di containerpython dependency injectioninject decoratorsservice containerfactory providersinversion of control
dependency-injectiontype-hints

More Application Frameworks packages