Skip to content

unnecessary-literal-within-tuple-call (C409) rule transforms single element list literals incorrectly #10323

@bardiharborow

Description

@bardiharborow

The unnecessary-literal-within-tuple-call (C409) rule detects the violation here:

tuple([1])

ruff check --fix --unsafe-fixes fails to transform the code correctly, resulting in this, which is not a tuple:

(1)

Instead it should transform the code to:

(1,)

Environment:

% ruff --version
ruff 0.3.2

% cat pyproject.toml
[tool.ruff]
lint.select = [
    "C4"
]

Metadata

Metadata

Labels

bugSomething isn't workingfixesRelated to suggested fixes for violationsgood first issueGood for newcomerslinterRelated to the linter

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions