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

[Feature Request] Alphabetically sort typing.Literal types #7220

Open
michaeloliverx opened this issue Sep 7, 2023 · 1 comment
Open

[Feature Request] Alphabetically sort typing.Literal types #7220

michaeloliverx opened this issue Sep 7, 2023 · 1 comment
Labels
rule Implementing or modifying a lint rule

Comments

@michaeloliverx
Copy link

I want the ability to alphabetically Literal types e.g.

from typing import Literal

# before
ErrorCode = Literal[
    "foo",
    "bar",
]

# after
ErrorCode = Literal[
    "bar",
    "foo",
]

This is related to #2315

I think having the ability to sort a range of things such as enums, literal collections, typed dict keys would be great. The rules should probably live in the RUF ruleset and perhaps be enabled / disabled via an action comment.

@charliermarsh
Copy link
Member

Makes sense, very similar to #1198 -- a different case of the same idea.

@charliermarsh charliermarsh added the rule Implementing or modifying a lint rule label Sep 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rule Implementing or modifying a lint rule
Projects
None yet
Development

No branches or pull requests

2 participants