Skip to content

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

Description

@MajorTanya

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

Metadata

Metadata

Labels

No labels
No labels

Type

Fields

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions