Flex DI

https://img.shields.io/pypi/v/flexdi.svg https://img.shields.io/endpoint.svg?url=https%3A%2F%2Factions-badge.atrox.dev%2Fcal-pratt%2Fflexdi%2Fbadge%3Fref%3Dmain&style=flat https://readthedocs.org/projects/flexdi/badge/?version=latest

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 Setup
    Minimize boilderplate by leveraging type annotations to resolve arguments. Allows user code to remain generic and reusable.
  • Inject Any Callable
    Provide any typed callable as an input to be invoked. Supports sync and async callables.
  • Resource Management
    Define dependencies as context managers and have their startup and shutdown logic invoked in a reliable order. Supports sync and async context managers.
  • Scoped Dependencies
    Clearly 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