Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Literals before imports sometimes aren't sorted #1792

Closed
willfrey opened this issue Jul 27, 2021 · 1 comment
Closed

Literals before imports sometimes aren't sorted #1792

willfrey opened this issue Jul 27, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@willfrey
Copy link

willfrey commented Jul 27, 2021

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:
    ...
@timothycrosley timothycrosley added the bug Something isn't working label Jul 28, 2021
timothycrosley added a commit that referenced this issue Jul 28, 2021
Fixed #1792: Sorting literals sometimes ignored when placed on first …
@willfrey
Copy link
Author

willfrey commented Jul 28, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants