Repository navigation
Description
Description
poetry remove deletes a dependency group that became empty, but it keeps an include-group that spells the group's name in a different form. The next command then fails.
_remove_references_to_group in remove.py compares item.get("include-group") == group_name literally. The dependency groups spec says: "Tools which handle Dependency Groups MUST normalize these names before comparisons." poetry lock already does: poetry-core's _configure_package_dependency_groups passes the raw name to dependency_group(), which canonicalizes it.
$ poetry lock # main at fc845fb, Python 3.12
Resolving dependencies...
Writing lock file
$ poetry remove six --lock
Resolving dependencies...
Writing lock file
$ grep '^ci' pyproject.toml
ci = [{ include-group = "lint-tools" }, "idna>=3"]
$ poetry lock; echo $?
Group 'ci' includes group 'lint-tools' which is not defined.
1
# control, group spelled lint-tools: ci = ["idna>=3"], poetry lock exits 0
# 2.5.1 from PyPI gives the same two results
# not run: the legacy [tool.poetry.group] include-groups path
The expected result is ci = ["idna>=3"], as with the control. Comparing canonicalize_name() of both sides would do it. #11192 / #11193 normalize --group and do not touch this comparison, and #11141 added the recursive cleanup around it.
Workarounds
Spell include-group exactly as the group key, or delete the dangling entry by hand.
Poetry Installation Method
other
- An editable install of main at fc845fb in a fresh venv, and
pip install poetry==2.5.1for the comparison.
Operating System
macOS 26.7
Poetry Version
Poetry (version 2.5.1), from main at fc845fb
Poetry Configuration
cache-dir = "~/Library/Caches/pypoetry"
data-dir = "~/Library/Application Support/pypoetry"
installer.builtin-uninstall = false
installer.max-workers = null
installer.no-binary = null
installer.only-binary = null
installer.parallel = true
installer.re-resolve = false
keyring.enabled = true
python.installation-dir = "{data-dir}/python"
requests.max-retries = 0
solver.lazy-wheel = true
solver.min-release-age = 0
solver.min-release-age-exclude = null
solver.min-release-age-exclude-source = null
system-git-client = false
virtualenvs.create = true
virtualenvs.in-project = true
virtualenvs.options.always-copy = false
virtualenvs.options.no-pip = false
virtualenvs.options.system-site-packages = false
virtualenvs.path = "{cache-dir}/virtualenvs"
virtualenvs.prompt = "{project_name}-py{python_version}"
virtualenvs.use-poetry-python = falseExample pyproject.toml
[project]
name = "demo"
version = "0.1.0"
requires-python = ">=3.11"
[dependency-groups]
Lint_Tools = ["six>=1"]
ci = [{ include-group = "lint-tools" }, "idna>=3"]
[tool.poetry]
packages = [{ include = "demo" }]Poetry Runtime Logs
$ poetry -vvv lock # after the remove, trimmed
ValueError
The dependency group "lint-tools" does not exist.
at .../poetry/core/packages/package.py:452 in dependency_group
...
Group 'ci' includes group 'lint-tools' which is not defined.I can open a PR with that change and a test for both spellings this week.
Activity
test: cover cleanup of differently spelled include-group references