https://github.com/celsiusnarhwal/poetry-sort
Alphabetically sort your Poetry dependencies
https://github.com/celsiusnarhwal/poetry-sort
dependencies poetry pyproject sorting
Last synced: 10 months ago
JSON representation
Alphabetically sort your Poetry dependencies
- Host: GitHub
- URL: https://github.com/celsiusnarhwal/poetry-sort
- Owner: celsiusnarhwal
- License: mit
- Created: 2022-12-25T04:37:59.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2025-03-03T17:41:45.000Z (about 1 year ago)
- Last Synced: 2025-05-05T08:56:45.689Z (10 months ago)
- Topics: dependencies, poetry, pyproject, sorting
- Language: Python
- Homepage: https://pypi.org/project/poetry-sort
- Size: 126 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# poetry-sort
[](https://pypi.org/project/poetry-sort)
[](https://pypi.org/project/poetry-sort)
[](https://github.com/celsiusnarhwal/poetry-sort/releases)
[](https://github.com/celsiusnarhwal/poetry-sort/blob/main/LICENSE.md)
[](https://github.com/psf/black)
poetry-sort is a [Poetry](https://python-poetry.org/) plugin that alphabetically sorts the dependencies in
your `pyproject.toml` file.
## Installation
```bash
poetry self add poetry-sort
```
## Usage
```bash
poetry sort
```
`poetry sort` supports the `--with`, `--without`, and `--only` options, which function identically to `poetry install`.
For full usage information, run `poetry sort --help`.
poetry-sort runs automatically whenever you run `poetry add` or `poetry init` and will sort only the dependency
groups that were modified by the command.
## Configuration
You can configure poetry-sort via the `tool.poetry.sort` section of `pyproject.toml`.
```toml
[tool.sort.config]
auto = true
case-sensitive = false
sort-python = false
format = true
```
The following options are available:
- `auto` (`bool`, default: `true`): Whether or not to automatically sort dependencies when running `poetry add`
or `poetry init`. `poetry sort` can always be run manually, regardless of this setting.
- `case-sensitive` (`bool`, default: `false`): Whether to take case into account when sorting.
- `sort-python` (`bool`, default: `false`): Whether to also sort the `python` dependency. If `false`, the `python`
dependency will be placed at the top of `tool.poetry.dependencies`; if `true`, it will be sorted alphebetically with
everything else.
- `format` (`bool`, default: `true`): Whether to apply some basic formatting to `pyproject.toml` after sorting.
If `true`, poetry-sort will :take all occurences of three or more consecutive newlines in `pyproject.toml` and
replace them with two newlines.
## License
poetry-sort is licensed under the [MIT License](https://github.com/celsiusnarhwal/poetry-sort/blob/main/LICENSE.md).