Skip to content

Allow setting default optionality for dependency groups #10550

@jaredahern

Description

@jaredahern

Issue Kind

Brand new capability

Description

Now that PEP 735 [dependency-groups] is supported, the [tool.poetry.group.GROUPNAME] tables can largely be omitted from pyproject.toml. However, it appears that in Poetry 2.2.0 they continue to have the same behavior as in previous versions, defaulting to optional = false. This is a reasonable choice, but given the ease by which (e.g.) a single group can be defined and requested for installation via command line, package developers may wish to declare most or all groups optional.

To accomplish this, propose defining a Boolean tool.poetry.default-group-optionality key in the configuration, itself having a default false value. This would expose and allow configuration of the default value for optional for all groups.

Alternatively, perhaps this key could be under tool.poetry.group somehow, but it is not immediately clear how it would be differentiated from a group name. Additionally, there may well be a clearer key name.

Impact

This would allow package developers to fully omit the [tool.poetry.group.GROUPNAME] tables from their pyproject.toml config. For configs with a large number of optional dependency groups, changing the default optionality could eliminate substantial extra complexity.

For comparison, I believe that pip only installs specifically-requested groups (see https://pip.pypa.io/en/latest/user_guide/#dependency-groups).

This change should be backwards compatible.

Workarounds

Specify the following for each optional group:

[tool.poetry.group.GROUPNAME]
optional = true

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/featureFeature requests/implementationsstatus/triageThis issue needs to be triaged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions