You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
fromtypingimportTypeVar, GenericVal=TypeVar("Val")
classMyGeneric(Generic[Val]):
def__call__(self, a: Val) ->Val: ...
T=TypeVar("T")
G=TypeVar("G", bound=MyGeneric)
deflistify_my_generic(g: G[T]) ->G[List[T]]: ... # error: Type variable "G" used with arguments
However it would be nice if the example above worked - the work around requires more typing and is only able to communicate what's happening so long as descriptive variable names are used.
This looks essentially the same as python/typing#548. Discussion can continue there. More generally, this is a type system enhancement and we generally discuss them in the typing issue tracker (or typing-sig@).
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]]
whereG
is any subclass ofMyGeneric
class. My current approach results in the commented error:Here's a playground link:
https://mypy-play.net/?mypy=0.750&python=3.8&gist=290ef32f0638a648674b98873a263d6f
The text was updated successfully, but these errors were encountered: