Skip to content

C420 fix should be marked unsafe for comment deletion #18764

@MeGaGiGaGon

Description

@MeGaGiGaGon

Summary

All of the other fixes in C4 are marked unsafe for comment deletion, except for C420, despite it still deleting comments. It should be marked unsafe and have the same fix safety comment about comments as the rest. playground

PS ~\Desktop\New_folder>Get-Content issue.py
{ # 1
a # 2
: # 3
None # 4
for # 5
a # 6
in # 7
iterable # 8
} # 9
PS ~\Desktop\New_folder>uvx ruff check issue.py --select C --fix --diff
--- issue.py
+++ issue.py
@@ -1,9 +1 @@
-{ # 1
-a # 2
-: # 3
-None # 4
-for # 5
-a # 6
-in # 7
-iterable # 8
-} # 9
+dict.fromkeys(iterable) # 9

Would fix 1 error.

Version

ruff 0.12.0 (87f0feb 2025-06-17) + playground

Metadata

Metadata

Assignees

No one assigned

    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