pydepi
A .NET-inspired, type-hint driven dependency injection container for Python.
pydepi resolves dependency graphs from constructor type annotations. It has no dependencies and knows nothing about the web — framework support ships as separate packages, so installing the container never drags a web framework into your environment.
pip install pydepi
from depi import ServiceCollection
class Config:
def __init__(self):
self.dsn = 'postgres://localhost/app'
class Database:
def __init__(self, config: Config): # resolved from the annotation
self.dsn = config.dsn
services = ServiceCollection()
services.add_singleton(Config)
services.add_scoped(Database)
provider = services.build_provider()
with provider.create_scope() as scope:
db = scope.resolve(Database)
Lifetimes
- Transient – a new instance on every resolution
- Singleton – one instance for the life of the provider
- Scoped – one instance per scope, typically per HTTP request
Scopes dispose their instances on exit, and async with awaits async cleanup first.
Framework integrations
Each is a separate distribution depending on this one:
| Package | Import |
|---|---|
pydepi-flask |
depi_flask |
pydepi-quart |
depi_quart |
pydepi-fastapi |
depi_fastapi |
pydepi-django |
depi_django |
Install one by name — pip install pydepi-flask. The extra pydepi[flask] works too, but the
distribution name is the more accurate form: these are separate packages, versioned and released
independently of core, not optional features of it.
Full documentation, including the integration guide, factories, and the async API, is in the project README.
License
MIT
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pydepi-0.1.0.tar.gz.
File metadata
- Download URL: pydepi-0.1.0.tar.gz
- Upload date:
- Size: 15.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c5c2b0a2cda485a3f20f4e05381ce9e74d2f37c034a1324effa9d7e01ffb52ee
|
|
| MD5 |
a57ecba48362e6748d6c39cd92b04019
|
|
| BLAKE2b-256 |
7b90f821e65a92fefeadea279ad1d43439171e93d6c11fb97d46a945c2c031c9
|
Provenance
The following attestation bundles were made for pydepi-0.1.0.tar.gz:
Publisher:
release.yml on danleonard-nj/depi
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pydepi-0.1.0.tar.gz -
Subject digest:
c5c2b0a2cda485a3f20f4e05381ce9e74d2f37c034a1324effa9d7e01ffb52ee - Sigstore transparency entry: 2691917217
- Sigstore integration time:
-
Permalink:
danleonard-nj/depi@847cbd30f3e2f5d11cd3fb4a261e37ae98e167b0 -
Branch / Tag:
refs/tags/pydepi-v0.1.0 - Owner: https://github.com/danleonard-nj
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@847cbd30f3e2f5d11cd3fb4a261e37ae98e167b0 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pydepi-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pydepi-0.1.0-py3-none-any.whl
- Upload date:
- Size: 15.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
70225dd714a97e2506223f6ee6958ee4e333b7216e7a2cff720da06cdb5a44b9
|
|
| MD5 |
76a14b79d337cc60a6cc62aeb1cd1e8f
|
|
| BLAKE2b-256 |
c6b0ac083a0111a68c9c2af27e44ec38cb8623c76eb4a155a49f2f32b37240b6
|
Provenance
The following attestation bundles were made for pydepi-0.1.0-py3-none-any.whl:
Publisher:
release.yml on danleonard-nj/depi
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pydepi-0.1.0-py3-none-any.whl -
Subject digest:
70225dd714a97e2506223f6ee6958ee4e333b7216e7a2cff720da06cdb5a44b9 - Sigstore transparency entry: 2691917243
- Sigstore integration time:
-
Permalink:
danleonard-nj/depi@847cbd30f3e2f5d11cd3fb4a261e37ae98e167b0 -
Branch / Tag:
refs/tags/pydepi-v0.1.0 - Owner: https://github.com/danleonard-nj
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@847cbd30f3e2f5d11cd3fb4a261e37ae98e167b0 -
Trigger Event:
push
-
Statement type: