poetry-sort is a Poetry plugin that alphabetically sorts the dependencies in
your pyproject.toml
file.
poetry self add poetry-sort
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.
You can configure poetry-sort via the tool.poetry.sort
section of pyproject.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 runningpoetry add
orpoetry 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 thepython
dependency. Iffalse
, thepython
dependency will be placed at the top oftool.poetry.dependencies
; iftrue
, it will be sorted alphebetically with everything else. -
format
(bool
, default:true
): Whether to apply some basic formatting topyproject.toml
after sorting. Iftrue
, poetry-sort will :take all occurences of three or more consecutive newlines inpyproject.toml
and replace them with two newlines.
poetry-sort is licensed under the MIT License.