-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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 for a missing classmethod decorator #11791
Comments
This works for me on latest import typing as tp
import enum
# @enum.unique
class ColorIndex(enum.IntEnum):
BLACK = 0
def _missing_(cls, value: object) -> tp.Any:
return ColorIndex.BLACK » mypy out/ex.py --strict-optional --warn-unreachable --show-traceback
out/ex.py:7: error: Signature of "_missing_" incompatible with supertype "Enum"
out/ex.py:7: note: Superclass:
out/ex.py:7: note: @classmethod
out/ex.py:7: note: def _missing_(cls, value: object) -> Any
out/ex.py:7: note: Subclass:
out/ex.py:7: note: def _missing_(cls, value: object) -> Any |
@sobolevn Thanks for the fix. I wonder if it is also possible to improve the main error message? Replace
with
? |
I think it is better to keep the existing format. It is way more informative. |
Agreed on the format. Still, the error message is going to be confusing. Please consider:
then
Without
The error message suggests I should change |
Any updates on this? |
Please consider
then mypy shows very confusing error (both signatures, for the subclass and the superclass, are the same)
The real issue is that
_missing_
should be decorated withclassmethod
.Python 3.10.1, mypy 0.930.
The text was updated successfully, but these errors were encountered: