ThirVondukr / aioinject

Async-first python dependency injection library
https://thirvondukr.github.io/aioinject/
MIT License
30 stars 2 forks source link

Function that has dependecies cannot be registered when using future annotations #13

Closed nrbnlulu closed 6 months ago

nrbnlulu commented 6 months ago

Example:

from __future__ import annotations
from dataclasses import dataclass

@dataclass
class  B:
    a: A

def get_b(a: A) -> B:
    return B(a)

class A: ...

cont = aioinject.Container()
cont.register(
    aioinject.Object(A()),
    aioinject.Singleton(get_b)
)