No project description provided
Project description
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")
Project details
Release history Release notifications | RSS feed
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)
Built Distribution
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | ab8ed9e9a21cb5f38173e2fffe41729f36d5dfc2173a016f0aace88a4b3b95c6 |
|
MD5 | b486898c5e0f00279d218444ecae0077 |
|
BLAKE2b-256 | 19f4616415d99741b9b00d454b0e544d189031b725ab55e12b102864b179f459 |
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | a2a9da81eef2a0958e61202f056f50789a3b8b3903421047d017c3435141b6a4 |
|
MD5 | 292a4cb1831a0e77db6aa3f3848790cb |
|
BLAKE2b-256 | fbadb11efb5993f7e2e6b456f44f8b443d3e112bc62ea957b2cbf914d3a660f2 |