python-poetry / python-poetry/poetry

Make version in `pyproject.toml` optional, or at least validate it *after* the plugins are run

Open
#4,299 9 comments 23 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

kind/feature status/triage
Dominant language
Python
Stars
34.3k
Forks
2.5k
Avg merge
2d 19h
Merged PRs (30d)
30

Description

  • I have searched the issues of this repo and believe that this is not a duplicate.
  • I have searched the documentation and believe that my question is not covered.

Feature Request

Thanks for Poetry! I'm a big fan. 🎉

I wanted to be able to keep my package versions in __init__.py, and with the new alpha supporting plugins I was able to create a plugin to read the version from it dynamically: https://github.com/tiangolo/poetry-version-plugin

But currently, Poetry checks and verifies if the version is set in pyproject.toml, and if it is not set there, it terminates with an error.

That means that even though the plugin is taking care of setting the package version, a dummy "version" is required in pyproject.toml, even though it is not really used.

My feature request is to make the version field optional in pyproject.toml.

Or alternatively, check if the version is set in the Poetry object in memory after running the plugins. That way my plugin can set the version.

Motivation

If users try to use that plugin (or any other similar one), they would have to set a version just to trick Poetry into thinking the pyproject.toml has all the fields, while the version is not really used in the end. So, for the final result, it's an extra workaround step.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing where Poetry validates the version in pyproject.toml and when plugins run; the issue names no files or tests. Compare making the field optional with validating the in-memory version after plugins, and consider the behavior for projects using dynamically supplied versions.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.