PyCQA / isort

A Python utility / library to sort imports.
https://pycqa.github.io/isort/
MIT License
6.49k stars 580 forks source link

Black profile: enable magic comma #2236

Open MrMino opened 8 months ago

MrMino commented 8 months ago

When black encounters a trailing comma in the from ... import list, it expands it vertically. Currently, isort --profile=black doesn't do that, which confuses people (including me :)), see #2128.

This PR enables split_on_trailing_comma, which is the default Black's behavior.

I wasn't sure if I should create a new changelog version header, so i omitted it, since that would require deciding whether this is PATCH or MINOR.


What Black does:

$ echo "from x import (a, b, c,)" | black -

from x import (
    a,
    b,
    c,
)
reformatted -

All done! ✨ 🍰 ✨
1 file reformatted.

What isort does currently:

$ echo "from x import (a, b, c,)" | isort --profile=black -

from x import a, b, c

After this change:

$ echo "from x import (a, b, c,)" | isort --profile=black -

from x import (
    a,
    b,
    c,
)