Tiny module-service and dependency injection framework
pip install symbiont
from symbiont import Module, Injectable, DependencyInjector
class BarService(Injectable):
x: int = 42
class FooService(Injectable):
bar: BarService
class ExampleModule(
Module,
providers=[BarService, FooService]
):
foo: FooService
class RootModule(
Module,
imports=[ExampleModule]
):
foo: FooService
injector = DependencyInjector()
root = injector.initialize(RootModule)
@injector.inject
def example_method(a, foo: FooService):
...