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 details)

Uploaded Source

Built Distribution

pyxdi-0.18.1-py3-none-any.whl (16.9 kB view details)

Uploaded Python 3

File details

Details for the file pyxdi-0.18.1.tar.gz.

File metadata

  • Download URL: pyxdi-0.18.1.tar.gz
  • Upload date:
  • Size: 15.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.10.2 Darwin/23.2.0

File hashes

Hashes for pyxdi-0.18.1.tar.gz
Algorithm Hash digest
SHA256 96cd1bf93915a572922e2653c0a346b3ef36bfa25cd52f6bcbd307fdb9f05193
MD5 35f31b608f3251b958850af8f917cfb0
BLAKE2b-256 fabf855dbf81c6b19bd07369f6cf73ef969f8883c2f838f3e7937fcb01cfb34d

See more details on using hashes here.

File details

Details for the file pyxdi-0.18.1-py3-none-any.whl.

File metadata

  • Download URL: pyxdi-0.18.1-py3-none-any.whl
  • Upload date:
  • Size: 16.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.10.2 Darwin/23.2.0

File hashes

Hashes for pyxdi-0.18.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a0d8659db93b913ec05e94bc7505dadc4f005c0f9f7675c1349a668acda63b21
MD5 c537cc128eaaec73d0e3c5e6b0fc11ec
BLAKE2b-256 3f461c4d0c6d33592e65ab465a33112b6bcf74d58361d345e25ea6520ac8566c

See more details on using hashes here.

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