Skip to content

C403 fix fails when a comma follows the list #16099

@dscorbett

Description

@dscorbett

Description

The fix for unnecessary-list-comprehension-set (C403) produces a syntax error when a comma follows the argument.

$ cat >c403.py <<'# EOF'
set([x for x in range(5)],)
# EOF

$ ruff --isolated check --select C403 c403.py --unsafe-fixes --diff 2>&1 | grep error:
error: Fix introduced a syntax error. Reverting all changes.

This is similar to #15852. I checked the rest of that series of rules and C403 seems to be the only one this bug still applies to.

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