Improve "override" error output #12466
Labels
diagnostics
topic-error-reporting
How we report errors
topic-inheritance
Inheritance and incompatible overrides
topic-usability
(Opening a new issue for this as discussed in #12390.)
Live demo: https://mypy-play.net/?mypy=latest&python=3.10&flags=strict&gist=d3e1a06857e4c6f1c698b7fa89e22f40
Example code:
Current mypy output:
It's somewhat helpful that mypy quotes the code in this error output, but it would be really helpful if mypy's output helped us zero in on exactly where the problem is, e.g.:
Note the addition of "in second overload" in the error message, as well as the all-important
^
arrows pointing to exactly where the supertype differs (namely,d
should be a keyword argument). Without the arrows, it's harder to see in the output that the only difference is the= ...
in the code for the superclass.This is exacerbated when method signatures are more complex than this, e.g.
MutableMapping.pop()
, where the current output makes it even harder to spot where the problem is compared to this minimized example (see #12390 (comment)). It is also exacerbated by mypy ignoring the signature in the actual implementation, whered
correctly appears as a keyword argument in the subclass. Finally, it can be exacerbated when upgrading to a mypy version that includes typeshed changes like this one: python/typeshed@92438dc#diff-b12c4be0f8e39f89957bbe7be6b6327185e18b69ea80a0f62c0746bb26f4a58eL478The text was updated successfully, but these errors were encountered: