Handle # fmt: skip followed by a comment (#4635)

This commit is contained in:
Tushar Sadhwani 2025-03-23 08:00:40 +05:30 committed by GitHub
parent 6144c46c6a
commit 2c135edf37
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 1 deletions

View File

@ -12,6 +12,7 @@
- Fix crash while formatting a long `del` statement containing tuples (#4628)
- Fix crash while formatting expressions using the walrus operator in complex
`with` statements (#4630)
- Handle `# fmt: skip` followed by a comment at the end of file (#4635)
### Preview style

View File

@ -321,7 +321,7 @@ def _generate_ignored_nodes_from_fmt_skip(
if not comments or comment.value != comments[0].value:
return
if prev_sibling is not None:
leaf.prefix = ""
leaf.prefix = leaf.prefix[comment.consumed :]
if Preview.fix_fmt_skip_in_one_liners not in mode:
siblings = [prev_sibling]

View File

@ -0,0 +1,6 @@
def foo():
pass
# comment 1 # fmt: skip
# comment 2