python-poetry / python-poetry/poetry
Extras dependencies listed in groups do not raise error.
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 34.3k
- Forks
- 2.5k
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 30
Description
Description
Buried in the documentation is a single line:
Dependencies listed in dependency groups cannot be specified as extras.
Strictly speaking, you'd never know it, since doing so works fine in your project itself (call it mylibrary). It's only when you go to depend on mylibrary[myextra] in a downstream repo does it become clear that the extra's dependencies are missing.
At least one of poetry lock, poetry build, or poetry publish ought to complain in this case.
Workarounds
Yes, but it is time-consuming to diagnose why dependencies are missing without a careful reading of the documentation.
Poetry Installation Method
other
Operating System
Ubuntu
Poetry Version
Poetry (version 1.8.2)
Poetry Configuration
cache-dir = "/home/REDACTED/.cache/pypoetry"
experimental.system-git-client = false
installer.max-workers = null
installer.modern-installation = true
installer.no-binary = null
installer.parallel = true
keyring.enabled = true
repositories.REDACTED.url = "REDACTED"
solver.lazy-wheel = true
virtualenvs.create = true
virtualenvs.in-project = null
virtualenvs.options.always-copy = false
virtualenvs.options.no-pip = false
virtualenvs.options.no-setuptools = false
virtualenvs.options.system-site-packages = false
virtualenvs.path = "{cache-dir}/virtualenvs" # /home/REDACTED/.cache/pypoetry/virtualenvs
virtualenvs.prefer-active-python = true
virtualenvs.prompt = "{project_name}-py{python_version}"
warnings.export = false
Python Sysconfig
No response
Example pyproject.toml
mylibrary:
[tool.poetry.dependencies]
dep = "1.0.0"
[tool.poetry.group.downstream.dependencies]
# With or without optional = true:
otherdep = "2.0.0"
[tool.poetry.extras]
myextra = ["otherdep"]
downstream repo:
[tool.poetry.dependencies]
mylibrary = { version = "*", extras = ["myextra"] }
dep = "*" # GOOD: Detects `dep` in `mylibrary`, pegged to 1.0.0 as expected.
otherdep = "*" # BAD: Does not detect `dep` in `mylibrary[myextra]`, gets 3.0.0.
### Poetry Runtime Logs
```bash session
N/A
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
Reproduce the example from the issue in pyproject.toml, then run poetry lock, poetry build, and poetry publish to identify which entry points accept the invalid extra. Trace dependency-group and extras validation from the failing command; done means at least one command reports that group dependencies cannot be specified as extras.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100