-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
bugmypy got something wrongmypy got something wrongtopic-type-ignore# type: ignore comments# type: ignore comments
Description
Expected behavior:
[case testErrorCodeWarnUnusedIgnores9_testUnusedIgnoreSloppyFormattingNotEmptyBrackets]
# flags: --warn-unused-ignores
1 + "ok" + "ok".foo # type: ignore[ operator,attr-defined]
1 + "ok" + "ok".foo # type: ignore[ ,operator,attr-defined] # E: Unused "type: ignore" comment [unused-ignore]
1 + "ok" + "ok".foo # type: ignore[ operator,attr-defined,] # E: Unused "type: ignore" comment [unused-ignore]
1 + "ok" + "ok".foo # type: ignore[ operator,attr-defined,,] # E: Unused "type: ignore" comment [unused-ignore]
[case testErrorCodeWarnUnusedIgnores10_testUnusedIgnoreSloppyFormattingEmptyBrackets]
# flags: --warn-unused-ignores
1+1 # type: ignore # E: Unused "type: ignore" comment [unused-ignore]
1+1 # type: ignore[] # E: Unused "type: ignore" comment [unused-ignore]
1+1 # type: ignore[ ] # E: Unused "type: ignore" comment [unused-ignore]
1+1 # type: ignore[,,, ] # E: Unused "type: ignore" comment [unused-ignore]
Actual behavior:
When there is a trailing comma, a leading comma, or other comma abuse, the error is Unused "type: ignore[]" comment
instead, because the empty string error code still counts.
I could easily have suppressed this symptom at the site of the unused ignores warning, but this seems like something that should probably be fixed at the source, to avoid other almost-invisible erroneous behavior from popping up later.
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongtopic-type-ignore# type: ignore comments# type: ignore comments