Skip to content

[refurb] Mark FURB180 fix as unsafe when comments would be deleted#22685

Closed
AndyBodnar wants to merge 1 commit intoastral-sh:mainfrom
AndyBodnar:fix-furb180-comments-unsafe
Closed

[refurb] Mark FURB180 fix as unsafe when comments would be deleted#22685
AndyBodnar wants to merge 1 commit intoastral-sh:mainfrom
AndyBodnar:fix-furb180-comments-unsafe

Conversation

@AndyBodnar
Copy link

Fixes #22631

The safe fix for FURB180 could delete comments that appear between keyword arguments. For example:

class C(
    other_kwarg=1,
    # comment
    metaclass=abc.ABCMeta,
):
    pass

The fix deletes from the previous argument to the end of the metaclass keyword, which would remove the comment. This change checks if any comments exist in that deletion range and marks the fix as unsafe if so.

Added a test case covering this scenario.

Fixes astral-sh#22631

The safe fix for FURB180 could delete comments between keyword arguments.
This change checks if comments exist in the deletion range and marks the
fix as unsafe if so.
@ntBre
Copy link
Contributor

ntBre commented Jan 18, 2026

Thanks for working on this! But this is already resolved in #22234, so I'll close this for now.

@ntBre ntBre closed this Jan 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Safe fix for FURB180 can delete comments

2 participants