PyCQA / PyCQA/isort

`--sort-reexports` does not retain trailing commas in short `__all__` exports

Open
#2,578 0 comments 1 reaction 2 assignees View on GitHub

@DanielNoord is already working on this.

Since Jul 16, 2026.

  • #2584 by @copilot-swe-agent — closed without merging
Dominant language
Python
Stars
7k
Forks
687
Avg merge
4h 56m
Merged PRs (30d)
2

Description

Hello everyone,

I noticed the --sort-reexports option in the 9.0.0b1 release and wanted to try it out (I hadn't noticed it before).

It works brilliantly, especially in the 9.0.0b1 pre-release, but I noticed that it does not retain trailing commas of an __all__ declaration, even with --profile black. I'm not sure if this is desired behaviour, especially when the __all__ length is too short to trigger black's chopping-down of the entries, but I wanted to at the very least highlight that this happens.

It's not a major problem, but it does clash a bit with the "one-per-line" style of __all__ declaration.

Reproduction:

my_package/__init__.py

from .first import FirstClass
from .second import SecondClass

- __all__ = (
-     "FirstClass",
-     "SecondClass",
- )
+ __all__ = ("FirstClass", "SecondClass")
The other files

my_package/first.py

class FirstClass:
    pass

my_package/second.py

class SecondClass:
    pass

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.