-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Unstable formatting with "# type: ignore" comment #1061
Comments
@msullivan is this related to any of the changes you made recently? |
I was able to bisect this to ca9ad69. |
Not related to any of the changes I made recently but I looked into it. The issue here is that the But then on the second run, it's not in the middle anymore, so black thinks it is safe to collapse everything onto one line. One fix to this would be to not have internal Another possibility could be to go the other direction and consider a type comment (just an ignore?) at the end uncollapsable also, so we stick with the version split on two lines? |
I open an issue on mypy python/mypy#7762 because when I use black + mypy and |
@IIBenII the next release of Black will be better at keeping |
@JelleZijlstra Thanks, I will wait :) |
`type: ignore` shouldn't block collapsing a line, since it will still apply fine to the merged line. This prevents an issue where a reformat causes it to shift lines and then be merged on a subsequent pass. There is a downside to this, which is that it can cause a `type: ignore` to apply to more code than was originally intended. There might be a way to apply this in a more limited situation, but I'm not sure what it is. Fixes psf#1061.
`type: ignore` shouldn't block collapsing a line, since it will still apply fine to the merged line. This prevents an issue where a reformat causes it to shift lines and then be merged on a subsequent pass. There is a downside to this, which is that it can cause a `type: ignore` to apply to more code than was originally intended. There might be a way to apply this in a more limited situation, but I'm not sure what it is. Fixes #1061.
Operating system: Arch Linux
Python version: 3.7
Black version: 19.3b0, 19.3b1.dev96+g57ab909
Does also happen on master: yes
I think I'm seeing a "INTERNAL ERROR: Black produced different code on the second pass of the formatter." which is different from others I find here (#954, #1042, #1044).
With this code:
I get this diff:
The text was updated successfully, but these errors were encountered: