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
Difference between builtins.type
and Type[Any]
#12933
Comments
Turns our It is hard for me, as a user, to understand why, as the error message I get is highly opaque:
I'd love for the error to contain a sort of delta between the concrete type and the protocol, explaining what is missing for the type to adhere to the protocol. @JelleZijlstra should I make separate issues for one or both of:
Or should we keep the discussion in here? |
I think make a new issue for the None/SupportsStr compatibiliity. The error message seems fine to me; it's pretty clear but just wrong. |
Not saying it is incorrect or unclear. It is both correct and clear, as you say. I'm claiming it is opaque. It only provides one bit of information: that the types are incompatible. It doesn't provide any hint as to how one could remediate the situation. If the message also said something about why the types are incompatible, it would make it easier for the developer to do one of the following:
This is a very simple protocol, with only one member, so it is clear to me that the type mismatch must come from mypy's understanding of |
Done: #13081 |
Bug Report
I have a protocol:
Surprisingly,
builtins.type
is compliant with this, whileType[Any]
isn't.To Reproduce
Link to mypy playground: https://mypy-play.net/?mypy=latest&python=3.11&gist=355a1b96812a523f6e374eb8ca6f4635
Expected Behavior
I would think both should be compliant, given that the
typing.Type
docs states that:Actual Behavior
Surprisingly,
builtins.type
is compliant with this, whileType[Any]
isn't.Your Environment
See link to mypy playground.
Mypy 0.960 and python 3.11
The text was updated successfully, but these errors were encountered: