Sorts functions and class methods according to the step-down rule
Project description
sdsort
Sorts top-level functions and class methods in Python files according to the step-down rule, as described in Robert C. Martin's Clean Code. More concretely, functions and methods are ordered in a depth-first-traversal order of the dependency tree, so higher-level code appears before lower-level code.
Installation
pip install sdsort
Or run directly with uv:
uvx sdsort <path>
Usage
To target individual files, run the sdsort command, followed by the paths to the files that should be sorted:
sdsort <file_1> <file_2>
To sort all *.py files in a directory, and all of its subdirectories, run the sdsort command followed by the directory path:
sdsort <directory_path>
To check if files are already sorted without modifying them, use the --check flag:
sdsort --check <file_or_directory>
This will exit with code 1 if any files would be re-arranged, making it suitable for CI pipelines and pre-commit hooks.
Maturity
It's early days. Consider this a beta for now.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sdsort-0.4.5.tar.gz.
File metadata
- Download URL: sdsort-0.4.5.tar.gz
- Upload date:
- Size: 7.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3d036de4a2404f591935b23eaa9f1a49cc21b9c353ef52bc349bfc6e93e2b408
|
|
| MD5 |
71c433506b3651cfa102eef756e62932
|
|
| BLAKE2b-256 |
08c9fcb2393c90f2ada298f65eb99df5f1ed5c253677ba65b237ee9bbb22f3e7
|
Provenance
The following attestation bundles were made for sdsort-0.4.5.tar.gz:
Publisher:
publish.yml on eirikurt/sdsort
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sdsort-0.4.5.tar.gz -
Subject digest:
3d036de4a2404f591935b23eaa9f1a49cc21b9c353ef52bc349bfc6e93e2b408 - Sigstore transparency entry: 1362978548
- Sigstore integration time:
-
Permalink:
eirikurt/sdsort@9dd07bc507edee3f9822486eb00627c75c99de6d -
Branch / Tag:
refs/tags/v0.4.5 - Owner: https://github.com/eirikurt
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9dd07bc507edee3f9822486eb00627c75c99de6d -
Trigger Event:
release
-
Statement type:
File details
Details for the file sdsort-0.4.5-py3-none-any.whl.
File metadata
- Download URL: sdsort-0.4.5-py3-none-any.whl
- Upload date:
- Size: 10.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
08615d093c0b5ee2e3b22c2b7810fbd12ba2fbcb9a9dc45729e1ed0bc04dfff3
|
|
| MD5 |
47d9b550392575752f07b8fd7ee0f8e4
|
|
| BLAKE2b-256 |
f18015f72abe136aba7df5d90934195a1e40ba4ccc09e6520af5a0845d29bd21
|
Provenance
The following attestation bundles were made for sdsort-0.4.5-py3-none-any.whl:
Publisher:
publish.yml on eirikurt/sdsort
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sdsort-0.4.5-py3-none-any.whl -
Subject digest:
08615d093c0b5ee2e3b22c2b7810fbd12ba2fbcb9a9dc45729e1ed0bc04dfff3 - Sigstore transparency entry: 1362978555
- Sigstore integration time:
-
Permalink:
eirikurt/sdsort@9dd07bc507edee3f9822486eb00627c75c99de6d -
Branch / Tag:
refs/tags/v0.4.5 - Owner: https://github.com/eirikurt
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@9dd07bc507edee3f9822486eb00627c75c99de6d -
Trigger Event:
release
-
Statement type: