Poetry
On this page
cooldown gates Poetry projects through --tool poetry.
What it reads#
A Poetry project is a pyproject.toml with its poetry.lock. Every package pyproject.toml
declares is a direct dependency, wherever it is declared:
[project]- an extra
- a PEP 735 dependency group
- a
[tool.poetry]main, group, or legacy development table
Registry#
Publish times come from PyPI.
How it is driven#
cooldown runs poetry, or the program COOLDOWN_POETRY names:
check: proves the lock current, as described below.upgradeandfix: move a package withpoetry add.--build: runspoetry install.
poetry add writes to the main dependencies. So upgrade and fix hold any package that
project.dependencies and [tool.poetry.dependencies] do not declare as not_eligible, rather
than add it there.
How check proves the lock current#
check asks Poetry itself whether a poetry.lock is current. It needs a stable Poetry 2.3 or
newer, the first release whose content hash covers PEP 735 [dependency-groups]. An older or
prerelease Poetry leaves the lock lock_unknown.
It runs poetry check --lock --no-plugins in the project:
- with the
poetrythatupgraderuns (COOLDOWN_POETRYorPATH); - with Poetry’s cache directory set to one in
cooldown’s cache directory; - with Python writing no bytecode.
Poetry’s check reads only pyproject.toml and the lock. So the probe needs no network, creates no
virtualenv, and leaves the project byte for byte as it was. Poetry’s warnings, such as one about
deprecated [tool.poetry] metadata, do not fail the check.
Poetry refuses a lock whose content hash no longer matches pyproject.toml, or a missing lock.
That refusal is a stale lock that --allow-stale-lock waives, but only when it is Poetry’s sole
error and everything else Poetry prints is a warning. Any other Poetry failure, such as an invalid
configuration or a missing README, is tool_failed.
Edge cases#
Poetry’s content hash covers the declarations, not what the lock resolved them to. So the lock is
lock_unknown rather than current wherever the probe cannot establish that the declarations decide
the resolution and that cooldown judges what the lock resolved:
- no
pyproject.tomlat the project root, where Poetry would check an enclosing project instead; pyproject.tomlor the lock changing while Poetry checks them;- a
lock-versionthat is missing or outside the formats Poetry’s installer reads, a stable version from 1 up to but excluding 3, which Poetry’s check passes but its installer refuses; - a lock that lists no packages while
pyproject.tomldeclares some; - a URL, git, or path origin, including a
develop = truepath, in a declaration or in the lock’s dependencies, whose content can change while its declaration stays the same; - a locked package from any source other than PyPI, or a
[[tool.poetry.source]]inpyproject.toml, sincecooldownjudges each package’s age by its PyPI release; project.dynamicinpyproject.toml, which changes how Poetry combines the[project]and[tool.poetry]declarations;- a plugin Poetry would load, required in
[tool.poetry.requires-plugins]or installed in the project’s.poetry/pluginsdirectory; - a lock whose content hash may not cover
[dependency-groups], which newer Poetry compares an older Poetry’s lock without: any lock written by Poetry 2.2, one written by an older Poetry whilepyproject.tomldeclares dependency groups, and one without a readable generator comment unless itslock-versionpredates 2.1 and no dependency group is declared.
A hand-edited version of a registry package in the lock still passes, since Poetry compares no
locked version, and cooldown evaluates the version the lock records.
uv and Poetry both own pyproject.toml, so at one root they take turns under upgrade, fix and
--lock; see Several ecosystems at once.