Skip to main content

No project description provided

Project description

Explicit DI

A library for explicit Dependency Injection

Tests pypi versions Docs license


Documentation: https://depeche-py.github.io/explicit-di/

Source code: https://github.com/depeche-py/explicit-di


Explicit DI is modern Python library for explicit Dependency Injection

Requirements

Python 3.9+

Installation

pip install explicit-di
# OR
poetry add explicit-di

Example

import explicit_di as _di


class A:
    pass


class B:
    def __init__(self, a: A, config : str):
        self.config = config
        self.a = a


class C:
    def __init__(self, b: B):
        self.b = b


def create_b(a: A):
    return B(a=a, config="foo")


def function_with_dependencies(one : int, two : str, my_c : C):
    print(my_c)


def main():
    container = _di.Container()
    container.register(A)
    container.register(B, create_b)
    container.register(C)

    b = container.resolve(B)
    assert isinstance(b, B)

    container.inject(function_with_dependencies, one=1, two="two")

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

explicit_di-0.1.2.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

explicit_di-0.1.2-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file explicit_di-0.1.2.tar.gz.

File metadata

  • Download URL: explicit_di-0.1.2.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for explicit_di-0.1.2.tar.gz
Algorithm Hash digest
SHA256 ab8ed9e9a21cb5f38173e2fffe41729f36d5dfc2173a016f0aace88a4b3b95c6
MD5 b486898c5e0f00279d218444ecae0077
BLAKE2b-256 19f4616415d99741b9b00d454b0e544d189031b725ab55e12b102864b179f459

See more details on using hashes here.

File details

Details for the file explicit_di-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: explicit_di-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for explicit_di-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a2a9da81eef2a0958e61202f056f50789a3b8b3903421047d017c3435141b6a4
MD5 292a4cb1831a0e77db6aa3f3848790cb
BLAKE2b-256 fbadb11efb5993f7e2e6b456f44f8b443d3e112bc62ea957b2cbf914d3a660f2

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