-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Odd error message for invalid use of tuple(): expected "Iterable[Never]" #19098
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
Tuple constructor takes |
Ah, yes, it's the same for any user-level function as well... from typing import Iterable, Never
def f[T](a: Iterable[T]) -> None:
pass
f(1) # main.py:6: error: Argument 1 to "f" has incompatible type "int"; expected "Iterable[Never]" [arg-type] |
It's hard to say what the type checker could usefully and accurately say here. Never is too narrow, Any is too broad, int (the actual value of T in this case) is also unhelpful). I guess the best option might be just printing the name of the typevar instead. |
But typevar name is also weird, some people use long-ish typevar names, and that can look like some "good" type one has to look up. Even short names like |
We used to use (I think any sort of proper solution for this is really hard, I would love an interface to explore a program and find what constraints are used for inference etc, but that's a massive undertaking...) |
Maybe instead of |
It's very easy, the |
tuple(1)
is invalid, of course. But what error message does it bring?Well that's odd! Considering that it can take iterables of all sorts of things, and not... impossible things.
In fact, this has to be wrong, because when I make my own function with Iterable[Never] argument, it doesn't like taking iterables of other things
The text was updated successfully, but these errors were encountered: