Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sdsort-0.4.3.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sdsort-0.4.3-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file sdsort-0.4.3.tar.gz.

File metadata

  • Download URL: sdsort-0.4.3.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for sdsort-0.4.3.tar.gz
Algorithm Hash digest
SHA256 90f11fb17f10169352895f96f0e200167a1a90a6861a5ef48e072b8f6b0c6f0d
MD5 9127676b17a8db3f1255527da544c13e
BLAKE2b-256 e23487dab34ce34c1961b4edb2796f1e16c1b1c4fd46f65a2507bdfb4faad05c

See more details on using hashes here.

Provenance

The following attestation bundles were made for sdsort-0.4.3.tar.gz:

Publisher: publish.yml on eirikurt/sdsort

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sdsort-0.4.3-py3-none-any.whl.

File metadata

  • Download URL: sdsort-0.4.3-py3-none-any.whl
  • Upload date:
  • Size: 9.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for sdsort-0.4.3-py3-none-any.whl
Algorithm Hash digest
SHA256 ba36d7e7553e40ecbbe8a2bf3d1304ef2685038b78fd823246e3e10d0ca3541a
MD5 5f44f3b07fc3a5a0c6ebc1025cdf6ee8
BLAKE2b-256 2c41a7a06432b1d51b5d1d03fe56bd71d34115fc08d02ee06f57b967b51e1446

See more details on using hashes here.

Provenance

The following attestation bundles were made for sdsort-0.4.3-py3-none-any.whl:

Publisher: publish.yml on eirikurt/sdsort

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page