Skip to content

poetry add --group and poetry remove --group do not match normalized group names #11192

Open

Description

@RaphaelFakhri

Description

PEP 735 compares dependency group names after normalization, and Poetry itself rejects two groups whose names normalize to the same value. poetry add --group and poetry remove --group compare the given name against the keys in pyproject.toml literally instead.

Given this pyproject.toml:

[project]
name = "p3"
version = "0.1.0"
requires-python = ">=3.13"
dependencies = []

[dependency-groups]
My_Group = ["six"]

[tool.poetry]
package-mode = false

poetry remove --group my-group six fails, even though poetry show --only my-group lists six:

$ poetry remove --lock --group my-group six

The following packages were not found: six

poetry add --group my-group attrs writes a second group, and the project becomes invalid:

[dependency-groups]
My_Group = ["six"]
my-group = [
    "attrs (>=26.1.0,<27.0.0)",
]
$ poetry lock

The Poetry configuration is invalid:
  - Duplicate dependency group name after normalization: my-group (My_Group, my-group)

The same happens with legacy [tool.poetry.group.My_Group] sections.

Expected behavior

--group my-group targets the existing My_Group group, as --only my-group and --with my-group already do.

Poetry version

main (6ecadf5), 2.5.1

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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