Skip to content

Black profile: enable magic comma#2236

Merged
staticdev merged 1 commit intoPyCQA:mainfrom
MrMino:black-magic-comma
Jan 17, 2025
Merged

Black profile: enable magic comma#2236
staticdev merged 1 commit intoPyCQA:mainfrom
MrMino:black-magic-comma

Conversation

@MrMino
Copy link
Contributor

@MrMino MrMino commented Feb 16, 2024

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,
)

Copy link
Member

@DanielNoord DanielNoord left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems sensible.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants