Explicit DI
A library for explicit Dependency Injection
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")
Release files for explicit-di 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| explicit_di-0.2.0.tar.gz | 3.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| explicit_di-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size:7.5 kB
Release files / explicit_di-0.2.0.tar.gz
| Download URL | explicit_di-0.2.0.tar.gz |
|---|---|
| Size | 3.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1bd5e17162cd4590f6c5593fdd0a09740e889dcf9132d49217dd4c4a00b96dd7
|
|
BLAKE2b-256 checksum How to use checksums |
9001b18c2ddb3967ed46dc42c8eb41844d46f0fa760ff9bf6faf9de4a7843a4d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.22
|
Release files / explicit_di-0.2.0-py3-none-any.whl
| Download URL | explicit_di-0.2.0-py3-none-any.whl |
|---|---|
| Size | 4.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
70fb4e9f4920778181bc2e83314d06a1da7225f7a1ae11b5f5c05ae3b9157447
|
|
BLAKE2b-256 checksum How to use checksums |
92cb177f8009226b5f494d715088b0902ea9541eba572917ef2d54cc36a9d1f6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.9.22
|