python-poetry / python-poetry/poetry
Allow setting default optionality for dependency groups
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 34.3k
- Forks
- 2.5k
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 30
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The payload names no implementation files or tests. Start by tracing Poetry 2.2.0's PEP 735 dependency-group support and handling of [tool.poetry.group.GROUPNAME] in pyproject.toml. Compare the current optional=false default with command-line group selection, then verify that omitted group tables and explicit optional values preserve backward compatibility.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- build-system, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100