-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Difference in line-length handling between ruff and black when line ends in # #8531
Comments
In general, we're far more careful with comment handling and therefore can wrap lines like that without fear of dropping comments accidentally. We explicitly exclude pragma comments from the line length #6772 We provide a |
Thanks, I think this will get me what I need although I suppose it's not clear how to support both disabling linting E501 and formatting on a single line -- I wonder if that's something ruff should support since it does both linting and formatting? Similar Seems this is a known divergence from |
Hm yeah I don't see a good way to do that cc @MichaReiser |
This works as expected, which seems reasonable to me? AAAAA_BBBBBBB_CCCC = "xxxxxxxx_xxxxxxxxxx_xxx_xxxxxxxx_xx_xxxx_xxxxxxx_xxxx_xxxx_xxxx_xxxxxxx_xxxx_xxxxx" # fmt: skip # noqa: E501 |
@charliermarsh that is formatted for me with
but it looks fixed in 0.1.4 so @dwyatte perhaps upgrade |
Ah okay, interesting. I'll close for now then. It does require that the skip comes before the noqa, but I think that's okay. |
Perfect, thanks all! |
Settings: Default ruff 0.1.3
Note: there is something specific about the example line below in terms of variable string length vs actual assignment value such that reproduction becomes difficult when changing the name/value, but this example captures the behavior I'm interested in raising in this issue
Example
When the line above is suffixed with a
#
e.g., to disable linting / formatting, black will not break it:https://black.vercel.app/?version=stable&state=_Td6WFoAAATm1rRGAgAhARYAAAB0L-Wj4AFEAGhdAD2IimZxl1N_WjPZmMnerqoaitTnd2a09E8Bi61KJWbnQshHGxfdai0l17K2DqAdXFD89RHKQ6jT30nA8Il4tW9g8JRaFzqeaQ-5TntovkAApVkiDMflIUXe64zjHKvCTRtNm3SZQwHmAKLERh2XSkjRAAGEAcUCAAD5YQM5scRn-wIAAAAABFla
Ruff however, will always break this line into
My code has some long constant names that I'd prefer not to split and apparently
# noqa: E501
is enough to exclude them from flake8 as well as black's formatting by virtue of how it handles lines ending in#
The text was updated successfully, but these errors were encountered: