Skip to main content

Easy-DI

Easy-DI is an easy to use Dependency Injection library.

Easy-DI allows you to implement the Dependency Injection pattern and manage the complexity of your Python applications.

Installing Easy-DI and Supported Versions

Easy-DI is available on PyPI:

$ python -m pip install easy-dependency-injection

Easy-DI officially supports Python 3.8+.

Key characteristics

  • Lightweight: the added overhead is comparable to accessing a module's constants
  • mypy-friendly: allows your IDE to infer the type of injected resources and help you with auto-complete and type hinting
  • Does one thing, does it well: it's just a dependency injection library.
  • Not invasive: you won't have to rewrite your application to use it; you can start taking advantage of the inversion of control gradually
  • Test-friendly: easy to integrate in your unit tests.

Known limitations

  • Only classes can be injected: no functions, no modules
  • Not tested with metaclasses
  • Performances decrease linearly with the number of injected resources

Example

from easy_di import DI, inject, injected


class Swallow:
    velocity: injected(str)

    def answer(self):
        return f"My airspeed velocity is {self.velocity}"

# this is needed only because the Swallow class is in the __main__ module,
# more realistic scenarios won't need the `inject` function call
inject(__name__)

if __name__ == "__main__":
    DI.register("velocity", "24 miles per hour")
    print(Swallow().answer())

Metadata

Release files for easy-dependency-injection 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for easy-dependency-injection 0.2.0
File Size Uploaded Provenance Actions
easy-dependency-injection-0.2.0.tar.gz 7.8 kB Without provenance Details for easy-dependency-injection-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for easy-dependency-injection 0.2.0
File Interpreter ABI Platform Actions
easy_dependency_injection-0.2.0-py3-none-any.whl Python 3 none any Details for easy_dependency_injection-0.2.0-py3-none-any.whl

Total release size: 17.0 kB

Release files / easy-dependency-injection-0.2.0.tar.gz

Download URL easy-dependency-injection-0.2.0.tar.gz
Size 7.8 kB
Tags Source
SHA-256 checksum
How to use checksums
c6d03f63e90951e838612715c904ecab76e8bbb8f90567b9831095ed2d52ff79
BLAKE2b-256 checksum
How to use checksums
a2201a50868651abd4dc833342fe454a350012f9e5ae6b2d913a1e3068ba75b6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.6

Release files / easy_dependency_injection-0.2.0-py3-none-any.whl

Download URL easy_dependency_injection-0.2.0-py3-none-any.whl
Size 9.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6a12b2d64d384801126195bde6076b1fd3e062e2d572cf1d838024a1917c13cc
BLAKE2b-256 checksum
How to use checksums
d67b9f4b193d945069d1000e52c604b62bc94ade5da444ac69ced9e4cb8b1273
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.6

Security for easy-dependency-injection 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page