Skip to content

fix(versions): name the version part that could not be read - #3881

Open
chiruu12 wants to merge 1 commit into
pdm-project:mainfrom
chiruu12:fix/version-part-error-message
Open

fix(versions): name the version part that could not be read#3881
chiruu12 wants to merge 1 commit into
pdm-project:mainfrom
chiruu12:fix/version-part-error-message

Conversation

@chiruu12

@chiruu12 chiruu12 commented Sep 7, 2026

Copy link
Copy Markdown

Fixes #3880

The catch-all else in Version.__init__ reported every part it could not read as a postrelease. An epoch, a local version, a dev release and a plain typo all arrived there and all got the same answer, which points the reader at a segment their string does not contain.

The message now names the part that failed and lists what the parser accepts:

1!1.0: '1!1' is not a valid part of a python version specifier.
Expected a number, a trailing '*', or a trailing prerelease such as 'a1', 'b2' or 'rc1'.

Nothing about what parses changes. Only the exception text moved. InvalidPyVersion is still what gets raised, so the two handlers in models/candidates.py are unaffected.

Six parametrized cases cover the misreported forms, plus 1.0.post1 so the one accurate use of the old wording stays pinned. All six fail on the parent commit. tests/models/: 228 passed, and ruff check and ruff format --check are clean.

Copilot AI lite review requested due to automatic review settings September 7, 2026 23:29

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@codecov

codecov Bot commented Sep 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.81%. Comparing base (f1bb362) to head (1c65681).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3881   +/-   ##
=======================================
  Coverage   88.81%   88.81%           
=======================================
  Files         120      120           
  Lines       13357    13357           
  Branches     2271     2271           
=======================================
  Hits        11863    11863           
  Misses        931      931           
  Partials      563      563           
Flag Coverage Δ
unittests 88.70% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Every unparseable version part is reported as a postrelease

2 participants