Flex DI
flexdi is a yet another Dependency Injection library for Python.
flexdi provides a lightweight alternative to common DI solutions
with minimal setup to be included in your projects. This library is
intended for use with type annotated Python libraries, as it leverages
these type annotations to perform injection.
Note
Flex DI is still a work in progress and is not yet intended
for production use-cases.
Be aware that APIs are likely to change in upcoming releases.
Goals
- Minimal SetupMinimize boilderplate by leveraging type annotations to resolve arguments. Allows user code to remain generic and reusable.
- Inject Any CallableProvide any typed callable as an input to be invoked. Supports sync and async callables.
- Resource ManagementDefine dependencies as context managers and have their startup and shutdown logic invoked in a reliable order. Supports sync and async context managers.
- Scoped DependenciesClearly define dependency lifetimes. Use
"application"scoped dependencies to provide singleton like objects. Use"request"scoped dependencies to allow short-term isolated usage.
Installation
You can install flexdi from pypi for supported interpreter versions
Python >=3.8.
$ pip install flexdi
Resources
Want to make a contribution?
See CONTRIBUTING.md