Skip to content

C408 fix changes behavior for non-NFKC identifier #16234

Description

@dscorbett

Description

The fix for unnecessary-collection-call (C408) changes the program’s behavior when a dict call’s keyword argument’s runtime name does not equal the name as it appears in the source code. This happens when the name in the source code isn’t normalized in NFKC.

$ cat >c408.py <<'# EOF'
print(dict(ℼ=3.14))
# EOF

$ python c408.py
{'π': 3.14}

$ ruff --isolated check --select C408 c408.py --unsafe-fixes --fix
Found 1 error (1 fixed, 0 remaining).

$ python c408.py
{'ℼ': 3.14}

Metadata

Metadata

Assignees

No one assigned

    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