Skip to content

Sort dependencies alphabetically and put them on separate lines in toml #5651

@nelsyeung

Description

@nelsyeung

Problem description

Can we sort dependencies alphabetically and put them in separate lines in the pixi.toml or pyproject.toml when we perform actions that manipulates the toml file? Package managers like uv and npm do this. This is done so that if people remove and add a package back in it won't create a diff or the diff is more meaningful.

For example, right now we run pixi add -f dev --pypi ruff mypy, it'll generate:

[dependency-groups]
dev = ["ruff>=0.15.5,<0.16",   "mypy>=1.19.1,<2"]

If we run pixi remove -f dev --pypi ruff && pixi add -f dev --pypi ruff, the toml becomes:

dev = ["mypy>=1.19.1,<2", "ruff>=0.15.5,<0.16"]

Now the diff exists even though technically nothing has been done.

Usually, people like to do this when they want to force the version to be pinned to a newer version in the toml; if it's sorted and placed on a new line then the diff is more obvious, e.g.,

dev = [
  "mypy>=1.19.1,<2",
-  "ruff>=0.14.14,<0.15",
+  "ruff>=0.15.5,<0.16",
]

Metadata

Metadata

Assignees

No one assigned

    Labels

    approvedThe Pixi maintainers welcome contributions to solve this issue or implement the feature/bugfix.enhancementNew featuresgood first issueGood for newcomershelp wantedMaintainers would like community input

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions