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
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:.
jolaf
changed the title
Error diagnostics incomplete on function redefinition
Error diagnostics incomplete on generic function redefinition
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.
Bug Report
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:
.To Reproduce
https://mypy-play.net/?mypy=1.11.2&python=3.12&enable-incomplete-feature=NewGenericSyntax&gist=78806d2f754ba0e5ce9bdcb61909fbc6
The text was updated successfully, but these errors were encountered: