unsorted-dunder-all (RUF022)#
Fix is sometimes available.
This rule is unstable and in preview. The --preview
flag is required for use.
What it does#
Checks for __all__
definitions that are not ordered
according to an "isort-style" sort.
An isort-style sort orders items first according to their casing: SCREAMING_SNAKE_CASE names (conventionally used for global constants) come first, followed by CamelCase names (conventionally used for classes), followed by anything else. Within each category, a natural sort is used to order the elements.
Why is this bad?#
Consistency is good. Use a common convention for __all__
to make your
code more readable and idiomatic.
Example#
Use instead:
Fix safety#
This rule's fix is marked as always being safe, in that
it should never alter the semantics of any Python code.
However, note that for multiline __all__
definitions
that include comments on their own line, it can be hard
to tell where the comments should be moved to when sorting
the contents of __all__
. While this rule's fix will
never delete a comment, it might sometimes move a
comment to an unexpected location.