Skip to main content

Dependency Injection library

Project description

PyxDI

PyxDI is a modern, lightweight and async-friendly Python Dependency Injection library that leverages type annotations (PEP 484) to effortlessly manage dependencies in your applications.

CI codecov Documentation Status


Documentation

http://pyxdi.readthedocs.io/


Requirements

Python 3.8+

and optional dependencies:

  • anyio (for supporting synchronous resources with an asynchronous runtime)

Installation

Install using pip:

pip install pyxdi

or using poetry:

poetry add pyxdi

Quick Example

app.py

from pyxdi import dep, PyxDI

di = PyxDI()


@di.provider(scope="singleton")
def message() -> str:
    return "Hello, world!"


@di.inject
def say_hello(message: str = dep) -> None:
    print(message)


if __name__ == "__main__":
    say_hello()

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

pyxdi-0.18.1.tar.gz (15.4 kB view hashes)

Uploaded Source

Built Distribution

pyxdi-0.18.1-py3-none-any.whl (16.9 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