Simple Dependency Injection framework
Project description
"That Depends"
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:
- 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()
- 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
Release history Release notifications | RSS feed
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)
Built Distribution
Close
Hashes for that_depends-1.7.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 157ca33fb9d818aa9f22066d02ed8faf8abe4c7e3f12ee5c052961aff3c9ed94 |
|
MD5 | a8a96ce8e9dc2ea8c2a3446a1a3c7c57 |
|
BLAKE2b-256 | 2d48548f351860f483fdb9f5f1a3e97686e01f2766943f85c9adea0d5d0bfb8d |