Skip to main content

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

pydepi-0.1.0.tar.gz (15.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pydepi-0.1.0-py3-none-any.whl (15.5 kB view details)

Uploaded Python 3

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

Hashes for pydepi-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c5c2b0a2cda485a3f20f4e05381ce9e74d2f37c034a1324effa9d7e01ffb52ee
MD5 a57ecba48362e6748d6c39cd92b04019
BLAKE2b-256 7b90f821e65a92fefeadea279ad1d43439171e93d6c11fb97d46a945c2c031c9

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydepi-0.1.0.tar.gz:

Publisher: release.yml on danleonard-nj/depi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for pydepi-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 70225dd714a97e2506223f6ee6958ee4e333b7216e7a2cff720da06cdb5a44b9
MD5 76a14b79d337cc60a6cc62aeb1cd1e8f
BLAKE2b-256 c6b0ac083a0111a68c9c2af27e44ec38cb8623c76eb4a155a49f2f32b37240b6

See more details on using hashes here.

Provenance

The following attestation bundles were made for pydepi-0.1.0-py3-none-any.whl:

Publisher: release.yml on danleonard-nj/depi

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page