8000 WithParents mypy: Type application only supported for generic classes · Issue #443 · reagento/dishka · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

WithParents mypy: Type application only supported for generic classes #443

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

Closed
lubaskinc0de opened this issue Apr 20, 2025 · 3 comments
Closed
Assignees
Labels
bug Something isn't working
Milestone

Comments

@lubaskinc0de
Copy link
Member
lubaskinc0de commented Apr 20, 2025

MRE

from typing import Protocol

from dishka import Provider, Scope, WithParents, make_container, provide


class Gateway(Protocol): ...


class ImplGateway(Gateway): ...


class MyProvider(Provider):
    scope = Scope.APP
    gateway = provide(WithParents[ImplGateway])
    # src/loyalty/application/__init__.py: note: In class "MyProvider":
    # src/loyalty/application/__init__.py:14:23: error: Type application is only supported for generic classes  [misc]


container = make_container(MyProvider())
gateway = container.get(Gateway)
print(gateway)  # <__main__.ImplGateway object at 0x7a2661497a10>
@Tishka17
Copy link
Member
Tishka17 commented Apr 20, 2025

I do not know how does it work

a: WithParents[ImplGateway] = ImplGateway()  # ok


class MyProvider(Provider):
    scope = Scope.APP
    gateway = provide(
        WithParents[ImplGateway]  # error
    )

@Tishka17 Tishka17 added the bug Something isn't working label Apr 24, 2025
@Tishka17
Copy link
Member

looks like we can try

WithParents: TypeAlias = T

we need that to check with mypy,pyright,pycharm

@Tishka17 Tishka17 added this to the 1.6 milestone Apr 24, 2025
@Tishka17 Tishka17 moved this to Ready in Dishka kanban Apr 24, 2025
@lubaskinc0de
Copy link
Member Author

i want to work on it

@Tishka17 Tishka17 moved this from Ready to In progress in Dishka kanban May 8, 2025
@Tishka17 Tishka17 closed this as completed May 8, 2025
@github-project-automation github-project-automation bot moved this from In progress to To be released in Dishka kanban May 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: To be released
Development

No branches or pull requests

2 participants
0