-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
I am fixing a large number of mypy errors in a code base that is automatically Black-reformatted.
I keep running in the issue where I must add a # type: ignore to the end of some line, and that takes it over the max length. Black reformats the line, keeping the # type: ignore at the end of the statement, but the mypy error is specific to some subexpression that's not on the last line after reformatting.
For example,
new_assocs = ViewNotificationRecipientAssoc.multiadd(assocs_to_add) # type: ignoreis reformatted as
new_assocs = ViewNotificationRecipientAssoc.multiadd(
assocs_to_add
) # type: ignorebut actually the error happens on the first line, so I must manually change this to
new_assocs = ViewNotificationRecipientAssoc.multiadd( # type: ignore
assocs_to_add
)(A similar thing happens to list literals and comprehensions.)
Can you please (even if only as an option) make it so that a # type: ignore comment is not considered to exceed the line length?
Note that for a regular type annotation (e.g. # type: List[int]) this is not a problem, so I'm fine with those being moved around. But # type: ignore is tied specifically to a line number.
I wouldn't bring this up if I didn't encounter this over and over.
CC: @msullivan