Skip to content

UP050 fix should be unsafe when it deletes a comment #18387

@dscorbett

Description

@dscorbett

Summary

When the fix for useless-class-metaclass-type (UP050) deletes a comment, it should be marked unsafe.

$ cat >up050.py <<'# EOF'
class C(
    object,  # Explicit is better than implicit.
    metaclass=type,
): ...
# EOF

$ ruff --isolated check up050.py --select UP050 --preview --fix
Found 1 error (1 fixed, 0 remaining).

$ cat up050.py
class C(
    object,
): ...

Version

ruff 0.11.12 (aee3af0 2025-05-29)

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingfixesRelated to suggested fixes for violationshelp wantedContributions especially welcome

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions