No project description provided
Project description
XDI Framework
XDI is a modern and declarative DI and IoC framework using pydantic for config and data.
Key features
- Fast: Very high performance thanks to pydantic and preemptive wiring
- Developer friendly: Declarative Container definition to take the "Magic" out of DI
- Good compatibility: Can be used with almost every framework and supports async
Installation (via git for now)
pip install git+https://github.com/Nictec/XDI
Basic Example
from pathlib import Path
from datetime import datetime
from pydantic import BaseModel
from adnexus.containers import DeclarativeContainer
from adnexus.config.builtin import TOMLLoader
from adnexus.config import load_config
from adnexus.providers import FactoryProvider
from adnexus.markers import Provide
from adnexus.decorators import inject
class UpstreamInjectable:
def __init__(self):
self.time = datetime.now()
def get_time(self):
return self.time
class TestInjectable:
def __init__(self, name: str, timer: Provide[UpstreamInjectable]):
self.timer = timer
self.name = name
def greet(self):
print(self.timer.get_time())
return f"Hello {self.name}"
@inject
def test(greeter: Provide[TestInjectable]):
print(greeter.greet())
class MyConfig(BaseModel):
name: str
class MyContainer(DeclarativeContainer):
# the loaded config can be accessed by calling MyContainer.config.<name>
config = load_config(TOMLLoader(Path("/path/to/settings.toml")))
injectables = [
FactoryProvider(TestInjectable, config.name),
FactoryProvider(UpstreamInjectable)
]
if __name__ == "__main__":
container = MyContainer()
container.wire([__name__])
test() # <-- dependencies are injected automatically
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
adnexus-0.1.1.tar.gz
(6.9 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file adnexus-0.1.1.tar.gz.
File metadata
- Download URL: adnexus-0.1.1.tar.gz
- Upload date:
- Size: 6.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.11.7 Linux/6.5.0-1017-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2cbef903160bd606d954d614231f1061c1f39cdcfb24ca82239c9c285bb615e7
|
|
| MD5 |
94d6d35105069e251f741079e2a8a6b8
|
|
| BLAKE2b-256 |
b8f85f789c42e1113b0feabaef17bdf8dc905ee927d0fce220222e1690efc70d
|
File details
Details for the file adnexus-0.1.1-py3-none-any.whl.
File metadata
- Download URL: adnexus-0.1.1-py3-none-any.whl
- Upload date:
- Size: 9.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.2 CPython/3.11.7 Linux/6.5.0-1017-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f3144aa7ecee8089a26c212449115db89268086ff9a2d48dbf43e8d6a32e3515
|
|
| MD5 |
75d0d09f12dc9fab93c8c0f3bafab954
|
|
| BLAKE2b-256 |
5d2c870749e4e5d7aba848d5e4f091c51717a564021809a5edb4c2061089bd28
|