Skip to main content

Simple Dependency Injection framework

Project description

"That Depends"

GitHub issues GitHub forks GitHub stars GitHub license

This package is dependency injection framework for Python, mostly inspired by python-dependency-injector.

It is production-ready and gives you the following:

  • Fully-async simple DI framework with IOC-container.
  • Python 3.10-3.12 support.
  • Full coverage by types annotations (mypy in strict mode).
  • FastAPI and Litestar compatibility.
  • Zero dependencies.
  • Overriding dependencies for tests.

Main characteristics:

  1. Fully async -> means every dependency resolving is async, so you should construct with await keyword:
from tests.container import DIContainer

async def main():
    some_dependency = await DIContainer.independent_factory()
  1. No wiring for injections in function arguments -> achieved by decision that only one instance of container is supported
from tests import container
from that_depends import Provide, inject


@inject
async def some_function(
        independent_factory: container.SimpleFactory = Provide[container.DIContainer.independent_factory],
) -> None:
    assert independent_factory.dep1

Quickstart

Install

pip install that-depends

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

that_depends-1.7.0.tar.gz (6.5 kB view hashes)

Uploaded Source

Built Distribution

that_depends-1.7.0-py3-none-any.whl (9.2 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page