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
{{ message }}
Repository navigation
Error diagnostics incomplete on generic function redefinition #17791
The provided test defines the generic function f() in two ways which are incompatible with each other – one has an upper bound, and the other has not.
mypy reports the error, but in the error message only one of the mismatching function signatures is displayed, the other one is missing for some reason.
Note that there's nothing in the output after the word Redefinition:.
changed the title [-]Error diagnostics incomplete on function redefinition[/-][+]Error diagnostics incomplete on generic function redefinition[/+]on Sep 19, 2024
The problem is that the second redefinition message is being suppressed here since it looks like a duplicate of the first definition and allow_dups is set to False in the ErrorInfo.
A possible fix would be to simply pass allow_dups=True so that the second message is never suppressed:
main.py:11: error: All conditional function variants must have identical signatures [misc]
main.py:11: note: Original:
main.py:11: note: def [F] f(a: F) -> F
main.py:11: note: Redefinition:
main.py:11: note: def [F] f(a: F) -> F
Found 1 error in 1 file (checked 1 source file)
A better fix would be to prevent the rendered definitions from being duplicates to begin with, which may come with the fix to #17792. But I think there would probably be no harm in setting allow_dups=True here anyway, since I can't think of a scenario where we'd want the message after Redefinition: to be suppressed.
Activity
[-]Error diagnostics incomplete on function redefinition[/-][+]Error diagnostics incomplete on generic function redefinition[/+]brianschubert commentedon Sep 20, 2024
Relevant snippet here is:
mypy/mypy/messages.py
Lines 1501 to 1511 in a646f33
The problem is that the second redefinition message is being suppressed here since it looks like a duplicate of the first definition and
allow_dupsis set toFalsein theErrorInfo.A possible fix would be to simply pass
allow_dups=Trueso that the second message is never suppressed:self.note("Redefinition:", defn) - self.pretty_callable_or_overload(new_type, defn, offset=4) + self.pretty_callable_or_overload(new_type, defn, offset=4, allow_dups=True)which results in the output:
A better fix would be to prevent the rendered definitions from being duplicates to begin with, which may come with the fix to #17792. But I think there would probably be no harm in setting
allow_dups=Truehere anyway, since I can't think of a scenario where we'd want the message afterRedefinition:to be suppressed.Fix TypeVar upper bounds sometimes not being displayed in pretty call…
Fix and simplify error de-duplication (python#19247)