Closed
Description
I just discovered the sorted literals feature, which is fantastic. One behavior I'm noticing is that if you have a literal before any imports, then isort
doesn't appear to pick up on that literal.
The following example won't have __all__
sorted:
"""I'm a docstring! Look at me!"""
# isort: unique-list
__all__ = ["Foo", "Foo", "Bar"]
from typing import final # arbitrary
@final
class Foo:
...
@final
class Bar:
...
However, these two examples appear to be fine and will have __all__
sorted correctly.
# Some top-level comment before the docstring.
# Maybe it's a copyright. It's probably a copyright.
"""I'm a docstring! Look at me!"""
# isort: unique-list
__all__ = ["Foo", "Foo", "Bar"]
from typing import final # arbitrary
@final
class Foo:
...
@final
class Bar:
...
"""I'm a docstring! Look at me!"""
from __future__ import annotations
# isort: unique-list
__all__ = ["Foo", "Foo", "Bar"]
from typing import final # arbitrary
@final
class Foo:
...
@final
class Bar:
...
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
Fixed #1792: Sorting literals sometimes ignored when placed on first …
Merge pull request #1793 from PyCQA/issue/1792-fix-literal-sort-at-top
willfrey commentedon Jul 28, 2021