Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a regression in Black’s # fmt: skip handling where multiline class/function headers could be collapsed when the skip comment appears on the compound statement’s colon line (e.g. class ...): # fmt: skip).
Changes:
- Prioritize detection of
# fmt: skipon compound-statement colon lines before the generic “same physical line” backtracking logic to preserve multiline headers intact. - Keep special handling for
asyncstatements when collecting ignored nodes for colon-line skips. - Add a regression fixture covering a multiline class base list with
# fmt: skipon the colon line.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tests/data/cases/fmtskip_class_header.py | Adds a regression case ensuring multiline class headers remain unchanged when # fmt: skip is on the colon line. |
| src/black/comments.py | Adjusts ignored-node generation ordering so colon-line # fmt: skip preserves entire multiline compound headers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
5 tasks
Collaborator
|
@17X61 Please expand the tests to include more edge cases |
Author
|
Added more regression coverage for multiline colon-line Validation run locally: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5112.
Summary
# fmt: skipon compound statement colon lines before same-line backtracking.ifheaders.Test Plan
python3 -m pytest tests/test_format.py -k fmtskip_class_header