[isort] Exclude pragma comments from line length calculation (I001) - #27313
Conversation
|
| code | total | + violation | - violation | + fix | - fix |
|---|---|---|---|---|---|
| unsorted-imports | 57 | 57 | 0 | 0 | 0 |
| unused-noqa | 1 | 1 | 0 | 0 | 0 |
| noqa-comments | 1 | 0 | 1 | 0 | 0 |
|
the all-or-nothing is_pragma_comment check misses mixed comments — something like |
| /// ) | ||
| /// ``` | ||
| fn add_comment_width(line_width: LineWidthBuilder, comment: &str) -> LineWidthBuilder { | ||
| if is_pragma_comment(comment) { |
There was a problem hiding this comment.
the width you skip here can come back as an E501: overlong.rs only strips a pragma when the line has exactly one comment (let [comment_range] = comment_ranges.comments_in_range(...)), but format_single_line concatenates every atop/inline/trailing comment onto the one line. so from m import x # explain # noqa: TID251 now stays unwrapped at, say, 95 chars and then line-too-long flags it because two comments in the range means no stripping at all.
There was a problem hiding this comment.
I added a test case which I think should demonstrate your concern
|
@Sanjays2402 @ntBre @MichaReiser how does this look? anything else we should do? |
|
I think it's just waiting for me/us to have a chance to review :) I remember it looking good last time I skimmed through. I am a bit confused by the ecosystem report, which is still showing stable changes, but Codex says it's just stale. I'll try to retrigger it when I review again. |
ntBre
left a comment
There was a problem hiding this comment.
Thank you! This is awesome, really well-written tests and comments, and it resolves several issues at once. Sorry for the delay!
I took care of the merge conflict, which will hopefully also trigger a fresh ecosystem run demonstrating that this is only a preview change.
isort] Exclude pragma comments from line length calculation (I001)
Summary
multiple issues arise of line length limits conflicting with per-line suppressions. it was proposed that pragmas should not be included in line length calculation. this is an attempt at that
fixes #12179
fixes #20042
fixes #27059
Test Plan