Join GitHub today
Improve error message for overload overrides w/ swapped variants #5369
This commit is intended to resolve #1270.
Currently, running mypy on the following program:
...will make mypy report the following error -- it considers the fact that we've swapped the order of the two variants to be unsafe:
This error message can be confusing for some users who may not be aware that the order in which your overloads are defined can sometimes matter/is something mypy relies on.
This commit modifies the error message to the following to try
As a misc note, one idea the issue I linked to above mentioned was that we could maybe print out the signature of the parent method. I decided not to do this for now because it felt inconsistent: we don't do this in other cases where the user incorrectly overrides a method.
If printing out the parent signature seems like a helpful thing to do in general, I'm happy to make a new PR w/ that change.