astral-sh / astral-sh/ruff

Implement ssort

Open
#3,946 16 comments 28 reactions 0 assignees View on GitHub
accepted plugin
Dominant language
Rust
Stars
49.6k
Forks
2.4k
Avg merge
2d 1h
Merged PRs (30d)
445

Description

Since Ruff already implements [isort](https://beta.ruff.rs/docs/rules/#isort-i), it would be nice to see [ssort](https://github.com/bwhmather/ssort) implemented as well.

This plugin automatically reorders the contents of a python file so that statements are placed after the things they depend making navigation easier within the file. For example (from the ssort GitHub page):
Before:
```py
from module import BaseClass

def function():
return _dependency()

def _decorator(fn):
return fn

@_decorator
def _dependency():
return Class()

class Class(BaseClass):
def public_method(self):
return self

def __init__(self):
pass
```
After:
```py
from module import BaseClass

class Class(BaseClass):
def __init__(self):
pass

def public_method(self):
return self

def _decorator(fn):
return fn

@_decorator
def _dependency():
return Class()

def function():
return _dependency()
```

Contributor guide

Open the contributing guide

Research direction

Start by reading Ruff's existing isort implementation and the linked ssort project to understand the intended dependency ordering. Use the before-and-after example as the behavioral reference; done means Ruff can reorder Python statements so dependencies and dependent definitions appear in the required order.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, rust
Domain
devtools, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.