uv-sort

raw JSON →
0.7.0 verified Mon Apr 27 auth: no python

Sorts dependencies in pyproject.toml or uv.lock files alphabetically, designed for use with the uv package manager. Current version 0.7.0, requires Python >=3.10. Released under MIT license; maintained actively with periodic updates.

pip install uv-sort
error Error: Failed to parse pyproject.toml: ...
cause Invalid TOML syntax in the file.
fix
Run tomlcheck or fix syntax errors manually.
error ValueError: Unsupported Python version: <3.10
cause Trying to install uv-sort on Python older than 3.10.
fix
Upgrade Python to 3.10+ or use a different tool.
error KeyError: 'dependencies'
cause The pyproject.toml does not have a [dependencies] table.
fix
Ensure your file includes [dependencies] or [tool.uv] sections.
gotcha The tool modifies files in-place by default. Use --check to dry-run.
fix Add --check flag to see changes without modifying.
gotcha uv-sort only sorts [dependencies] and [dev-dependencies], not [build-system] or [tool] sections.
fix Manually sort other sections if needed.
gotcha Ensure your pyproject.toml is valid TOML; malformed files cause parse errors.
fix Validate with `toml` library before sorting.
uv tool install uv-sort

Sort dependencies in a pyproject.toml file using the Python API.

import uv_sort
result = uv_sort.sort("pyproject.toml")
print(result)