Skip to content

C400 unsafe fix is more unsafe than the documentation suggests #11603

@simonpercivall

Description

@simonpercivall

Ruff 0.45

The C400 unsafe fix says that that it sometimes drops comments. It may also generate broken code:

ruff check fix --unsafe-fixes --select C400

list(
    (1 for _ in range(1))
)

expected

[
    1 for _ in range(1)
]  # [1]

actual

[
    (1 for _ in range(1))
]  # [<generator object <genexpr> at ...>

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingfixesRelated to suggested fixes for violations

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions