Skip to content

RUF022 autofix should be marked unsafe if there are own-line comments between __all__ items #14552

@phil65

Description

@phil65
  • I searched issues for __all__, couldnt see anything from today.

Since 0.8.0, ruff wants to sort my __all__ array.
Thats generally very nice, but it also messes up something like.

__all__ = [
    # Core components
    "TaskManager",
    "TaskExecutor",
    # Models
    "TaskContext",
    "TaskProvider",
    "TaskResult",
    # Utilities
    "execute_concurrent",
]

gets sorted to:

__all__ = [
    # Models
    "TaskContext",
    "TaskExecutor",
    # Core components
    "TaskManager",
    "TaskProvider",
    "TaskResult",
    # Utilities
    "execute_concurrent",
]

So it messes up the groups.
Comments are only attached to one item instead of the group when sorting. I am not sure if that is a good assumption. Perhaps ignore sorting it when comments are inside the all array?

Thanks! :)

Metadata

Metadata

Assignees

Labels

fixesRelated to suggested fixes for violations

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions