Skip to content

Black -C doesn't remove trailing commas in indices #3204

Closed as not planned
Closed as not planned
@TomFryers

Description

Describe the bug
Trailing commas inside indexing square brackets are not removed when running Black with -C. This also affects generic types with multiple parameters.

To Reproduce

For example, take this code:

x = [0, 1,]
x = z[0, 1,]

and run with -C. We get

x = [0, 1]
x = z[0, 1,]

Expected behavior

The final trailing comma should disappear.

x = z[0, 1]

Environment

  • Black's version: 22.6.0. Also tested on main on the playground, and with/without --preview.
  • OS and Python version: Linux/Python 3.10.5

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    F: trailing commaFull of magicR: duplicateThis issue or pull request already existsT: bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions