-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Unpack generic tuple with no args not working #19140
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
Comments
Your code doesn't type check because you haven't specialized the generic You can fix this by changing the last line to: Class[()]().foo(x_no_args) |
Ah, thanks didn't know that! 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. Here's the error I got:
|
I made a fork and added a test case to investigate it but realized it seems to be working as expected on the latest mypy (1.16 vs 1.15 at time of issue report) Thanks! |
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: