-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Description
I've posted about this on gitter but haven't gotten a response. Could someone help me understand how I would construct the type spec for a function def (G[T]) -> G[List[G]]
where G
is any subclass of MyGeneric
class. My current approach results in the commented error:
from typing import TypeVar, Generic
Val = TypeVar("Val")
class MyGeneric(Generic[Val]):
def __call__(self, a: Val) -> Val: ...
T = TypeVar("T")
G = TypeVar("G", bound=MyGeneric)
def listify_my_generic(g: G[T]) -> G[List[T]]: ... # error: Type variable "G" used with arguments
Here's a playground link:
https://mypy-play.net/?mypy=0.750&python=3.8&gist=290ef32f0638a648674b98873a263d6f
schneiderfelipe, ringohoffman, juliusHuelsmann, JotaRata, yanghanlin and 2 more
Metadata
Metadata
Assignees
Labels
No labels