Skip to content

Sorting of dependency-groups is non-alphabetical #53

@ddeepwell

Description

@ddeepwell

I am adding dependency-groups (see this and this) to my pyproject.toml file and find that the sorting of the groups within the dependency-groups section is non-alphabetical.

Given the following pyproject.toml file:

[project]
name = "example"
version = "0.1.0"
requires-python = ">=3.11"
classifiers = [
  "Programming Language :: Python",
  "Programming Language :: Python :: 3 :: Only",
  "Programming Language :: Python :: 3.11",
  "Programming Language :: Python :: 3.12",
]
dependencies = [  ]

[dependency-groups]
coverage = [ "coverage>=7", { include-group = "test" } ]
dev = [
  { include-group = "lint" },
  { include-group = "test" },
  { include-group = "type" },
]
docs = [ "furo==2024.8.6", "sphinx>=8" ]
lint = [ "flake8>=6.1" ]
sast = [ "bandit>=1.7" ]
test = [ "pytest>=8.2" ]
type = [ "mypy>=1.5" ]

[tool.pyproject-fmt]
max_supported_python = "3.12"

executing pyproject-fmt pyproject.toml converts the pyproject.toml file into:

[project]
name = "example"
version = "0.1.0"
requires-python = ">=3.11"
classifiers = [
  "Programming Language :: Python",
  "Programming Language :: Python :: 3 :: Only",
  "Programming Language :: Python :: 3.11",
  "Programming Language :: Python :: 3.12",
]
dependencies = [  ]

[dependency-groups]
dev = [
  { include-group = "lint" },
  { include-group = "test" },
  { include-group = "type" },
]
test = [ "pytest>=8.2" ]
type = [ "mypy>=1.5" ]

docs = [ "furo==2024.8.6", "sphinx>=8" ]
coverage = [ "coverage>=7", { include-group = "test" } ]
lint = [ "flake8>=6.1" ]
sast = [ "bandit>=1.7" ]

[tool.pyproject-fmt]
max_supported_python = "3.12"

This sorting also introduced a single empty line which breaks up the visual connection of all dependency groups.

I had expected the sorting to be alphabetical by the dependency group name and to not create new spaces.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions