Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generics support #37

Closed
Tishka17 opened this issue Feb 10, 2024 · 1 comment
Closed

Generics support #37

Tishka17 opened this issue Feb 10, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@Tishka17
Copy link
Member

Let's image we have 3 classes:

class C(Generic[T]):
    pass

class Gw(Generic[T]):
    def __init__(self, c: C[T]): ...

class U:
    def __init__(self, Gw[Model]): ...

We should not declare factories for concrete intermediate classes like Gw in example. E.g. this is expected to work:

class MyProvider(Provider):
    @provide(scope=Scope.APP)
    def c_model(self) -> C[Model]: 
       return CModelImpl()

    gw = provide(Gw, scope=Scope.APP)
    u = provide(U, scope=Scope.APP)
...

container.get(U)
@Tishka17
Copy link
Member Author

Fixed for concrete versions, e.g. provide(U[SomeModel])

@Tishka17 Tishka17 added the enhancement New feature or request label Feb 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant