-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Confusing error message when using AnyStr #963
Comments
The error message is pretty confusing and this has came up before. I think Guido gave a talk about A better message would show all argument types and enumerate all the valid signatures. A similar thing should be done for overloaded functions. Potential error message (we should iterate on this):
This gets a little complicated if there are keyword arguments, etc. Maybe we could point to the definition of |
What about including this in a milestone, now that we've been improving error messages? This must be one of the worst error messages users will commonly encounter. |
I will look into this. |
For reference, this now outputs:
which does direct the user towards the problem a little more; the confusing reference to "object" is still present. |
Also, this: from typing import AnyStr
class One(str):
pass
class Two(str):
pass
OneTwo = TypeVar('OneTwo', One, Two)
def g(x: OneTwo, y: OneTwo) -> None:
print(x + y)
g(One('a'), Two('b')) does not resolve to
|
Currently this outputs:
which is arguably worse. I think this is another entry for the
topic-join-v-union
For comparison pyright says:
|
This correctly fails to typecheck because the second arg is bytes, but the error message is hard to follow:
The text was updated successfully, but these errors were encountered: