Question about tool.poetry.version and PEP 621 for plugin development
#9976
Replies: 2 comments 2 replies
-
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.
-
|
@mtkennerly Unrelated, but I thought you may want to check if |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
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.versionand setproject.version, then removeproject.versionand restore the originaltool.poetry.version. The plugin could leavetool.poetry.versionalone 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.versionis 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.versionoptional whenprojectis being used andproject.dynamiccontains"version"? In that case, the plugin wouldn't need to removetool.poetry.versionin the first place, and there wouldn't be any formatting issue when cleaning up the changes. Or how about silencing the warning whenproject.dynamicis 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