Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please don't break long lines if a '# type: ignore' takes it over the max length #997

Closed
gvanrossum opened this issue Aug 27, 2019 · 1 comment · Fixed by #1040
Closed

Comments

@gvanrossum
Copy link

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: ignore

is reformatted as

            new_assocs = ViewNotificationRecipientAssoc.multiadd(
                assocs_to_add
            )  # type: ignore

but 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

@gvanrossum
Copy link
Author

gvanrossum commented Oct 3, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant