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 would like a generic class with TypeVarTuple and connect a callback as parameter to a member function. This works for instances of the object created with one or more type arguments, but fails for no types.
Your code doesn't type check because you haven't specialized the generic Class in the last line of your code sample. In all previous cases, you've correctly supplied a specialization for the TypeVarTuple.
Now for a slight variation. Ideally I'd like to supply a default empty tuple and use the generic class without explicit specialization. This seems to work when an object is instantiated and has its type inferred but not for type annotated variables: mypy playground. The intended use case is for annotated class variables that are instantiated in a metaclass.
This appears to work as expected in pyright
Here's the error I got:
error: Invalid self argument "Class[*tuple[*tuple[()], ...]]" to attribute function "foo" with type "Callable[[Class[*Ts], Callable[[VarArg(*Ts)], None]], None]" [misc]
Uh oh!
There was an error while loading. Please reload this page.
Bug Report
I would like a generic class with TypeVarTuple and connect a callback as parameter to a member function. This works for instances of the object created with one or more type arguments, but fails for no types.
To Reproduce
https://mypy-play.net/?mypy=latest&python=3.13&gist=9176cff57ec791ec0bd9d49e17b1e85e
Expected Behavior
Mypy should allow unpacking the TypeVarTuple to a Callable with no arguments.
Actual Behavior
error: Argument 1 to "foo" of "Class" has incompatible type "Callable[[], None]"; expected "Callable[[VarArg(Never)], None]" [arg-type]
Your Environment
mypy playground
mypy.ini
(and other config files):The text was updated successfully, but these errors were encountered: