Question about tool.poetry.version
and PEP 621 for plugin development
#9976
Replies: 1 comment 1 reply
-
Is it possible to leave
Because otherwise Poetry will fail (without a plugin).
Unfortunately, that would be a broken config (without a plugin).
Having version in |
Beta Was this translation helpful? Give feedback.
-
Hi! I maintain a plugin for dynamic versioning. It temporarily modifies pyproject.toml while Poetry is running and then cleans up after itself. For Poetry 2.0.0 and PEP 621, that means (ignoring some other details to keep the discussion simple) it needs to first remove
tool.poetry.version
and setproject.version
, then removeproject.version
and restore the originaltool.poetry.version
. The plugin could leavetool.poetry.version
alone and just add/removeproject.version
, but that produces a warning frompoetry check
:However, when the plugin restores
tool.poetry.version
, tomlkit doesn't necessarily put it in the same place, which causes some friction for users (mtkennerly/poetry-dynamic-versioning#203). That in and of itself isn't a Poetry issue, but I'm wondering about whytool.poetry.version
is required here and if making it optional would allow plugins to avoid the formatting issue to begin with. Would it be possible for Poetry to maketool.poetry.version
optional whenproject
is being used andproject.dynamic
contains"version"
? In that case, the plugin wouldn't need to removetool.poetry.version
in the first place, and there wouldn't be any formatting issue when cleaning up the changes. Or how about silencing the warning whenproject.dynamic
is set appropriately?I'm not sure if this is an X/Y problem. If there's a different solution or expected way for plugins to handle this, please let me know.
(You might suggest simply reverting the entire file for clean-up instead of restoring specific data, but that won't work if Poetry itself or some other plugin also needs to retain modifications to pyproject.toml during the same command. Therefore, the plugin tries to selectively revert only its own changes.)
Beta Was this translation helpful? Give feedback.
All reactions