You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Annotation of property of derived class with -> Any makes mypy complain about incompatibility with base class. The exact rtype doesn't matter, the error is still the same. The MRE is a simplified version of stubgen output.
MRE:
fromtypingimportAnyclassA:
doc=""classB(A):
# remove "-> Any" to make mypy happy@propertydefdoc(self) ->Any:
return""
Expected: no errors reported
Actual:
foo.py:11: error: Signature of "doc" incompatible with supertype "A"
Found 1 error in 1 file (checked 1 source file)
command line command:mypy foo.py
version info:
mypy: 0.790+dev.ffdbeb3d47ccb2d9691b36993be0a18e0718d997
python: 3.7.3
P.S.: The error message of Signature of "doc" incompatible with supertype "A" should be more descriptive. It's good enough for simple cases, but rather cryptic for more involved examples. (I realize it might be not so trivial to propagate the root source of incompatibility and represent it nicely)
The text was updated successfully, but these errors were encountered:
The error message is kind of reasonable, since doc is mutable in A but not in B. If you don't have an annotation, mypy treats the code as untyped and omits various checks.
The error message of Signature of "doc" incompatible with supertype "A" should be more descriptive
I think that mypy sometimes produces a better message, but not in this case. Would you like to create a separate issue about the better error message?
example.py:9: error: Signature of "doc" incompatible with supertype "A"
example.py:10: error: Signature of "doc" incompatible with supertype "A"
Found 2 errors in 1 file (checked 1 source file)
At the moment I'm not sure what makes mypy complain about this snippet to file another issue.
classB(A):
doc=RevealAccess(10, 'var "x"')
# Incompatible types in assignment (expression has type "RevealAccess", base class "A" defined the type as "str")
(bug report)
Annotation of property of derived class with
-> Any
makesmypy
complain about incompatibility with base class. The exact rtype doesn't matter, the error is still the same. The MRE is a simplified version ofstubgen
output.MRE:
Expected: no errors reported
Actual:
command line command:
mypy foo.py
version info:
mypy: 0.790+dev.ffdbeb3d47ccb2d9691b36993be0a18e0718d997
python: 3.7.3
P.S.: The error message of
Signature of "doc" incompatible with supertype "A"
should be more descriptive. It's good enough for simple cases, but rather cryptic for more involved examples. (I realize it might be not so trivial to propagate the root source of incompatibility and represent it nicely)The text was updated successfully, but these errors were encountered: