Skip to content

fix(formats): parse multi-constraint and v-prefixed Poetry versions - #3860

Merged
frostming merged 1 commit into
pdm-project:mainfrom
deepspace28:fix/poetry-specifier-comma-and-v-prefix
Aug 29, 2026
Merged

fix(formats): parse multi-constraint and v-prefixed Poetry versions#3860
frostming merged 1 commit into
pdm-project:mainfrom
deepspace28:fix/poetry-specifier-comma-and-v-prefix

Conversation

@deepspace28

Copy link
Copy Markdown
Contributor

The operator group of VERSION_RE matched any non-digit character. In a multi-constraint string that swallowed the separating comma into the next operator, which was then re-emitted verbatim:

>>> from pdm.formats.poetry import _convert_specifier
>>> _convert_specifier(">=1.0,<2.0")
">=1.0,,<2.0"
>>> _convert_specifier(">=1.2,!=1.5,<2.0")
">=1.2,,!=1.5,,<2.0"

SpecifierSet happens to tolerate the empty item, so this is not fatal, but every imported multi-constraint dependency lands in pyproject.toml with a doubled comma.

The same group also absorbed a v prefix, which Poetry accepts, leaving an operator of ^v that matched no branch and passed straight through:

>>> _convert_specifier("^v1.2.3")
"^v1.2.3"   # InvalidSpecifier

Restricting the group to the operator characters Poetry actually uses and skipping an optional v fixes both. Behaviour is unchanged for every other form I could find - bare versions, wildcards, epochs, spaced operators, ~/^ bounds.

Covered by a parametrized test alongside the existing caret/tilde ones.

@codecov

codecov Bot commented Aug 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.77%. Comparing base (db7cc17) to head (8e03922).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3860   +/-   ##
=======================================
  Coverage   88.77%   88.77%           
=======================================
  Files         120      120           
  Lines       13312    13312           
  Branches     2262     2262           
=======================================
  Hits        11818    11818           
  Misses        931      931           
  Partials      563      563           
Flag Coverage Δ
unittests 88.66% <100.00%> (ø)

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.

@frostming

Copy link
Copy Markdown
Collaborator

@deepspace28 please resolve the conflicts

The operator group of VERSION_RE matched any non-digit character, so in a
multi-constraint string the separating comma was captured as part of the
next operator and re-emitted: >=1.0,<2.0 became >=1.0,,<2.0. Restrict the
group to the operator characters Poetry uses and skip an optional v
prefix, which Poetry also accepts (^v1.2.3).
@deepspace28
deepspace28 force-pushed the fix/poetry-specifier-comma-and-v-prefix branch from 5fb798d to 8e03922 Compare August 29, 2026 05:03
@deepspace28

Copy link
Copy Markdown
Contributor Author

Rebased on main, conflicts resolved. Kept both new tests in tests/test_formats.py.

@frostming
frostming merged commit bf6f64b into pdm-project:main Aug 29, 2026
25 checks passed
halstead pushed a commit to openembedded/openembedded-core that referenced this pull request Aug 30, 2026
Source: CHANGELOG.md

## Release v2.29.0 (2026-08-29)

### Features & Improvements

- Export editable local dependencies with relative paths in requirements files. ([#3294](pdm-project/pdm#3294))
- Extend `pdm run` with `--env`, `--env-file` and `--working-dir` options to set or override the corresponding script options dynamically. ([#3829](pdm-project/pdm#3829))

### Bug Fixes

- Restrict a locked package to the platform it was resolved for when it doesn't belong to every lock target, so `pdm lock --platform ... --append` no longer adds entries that get installed on the other targets. ([#3261](pdm-project/pdm#3261))
- Keep Poetry `include` entries restricted to the sdist format when importing, writing them to `tool.pdm.build.source-includes` instead of dropping them. ([#3854](pdm-project/pdm#3854))
- Accept `--no-verify-ssl` on `pdm publish`, which was misspelled as `--no-very-ssl`. The old spelling keeps working as an alias. ([#3857](pdm-project/pdm#3857))
- Convert Poetry tilde constraints with fewer than three components to the bounds Poetry means: `~1.2` becomes `<1.3` rather than `<2.0`, and `~1` no longer produces an invalid `~=1` specifier that aborts the import. ([#3858](pdm-project/pdm#3858))
- Keep the separating comma out of the operator and accept a `v` prefix when converting Poetry version constraints. ([#3860](pdm-project/pdm#3860))
- Keep importing a Poetry project when an author or maintainer entry does not fit the `Name <email>` pattern. ([#3861](pdm-project/pdm#3861))
- Skip `requires-python` when a Pipfile `[requires]` table has no python version, instead of writing `>=None`. ([#3862](pdm-project/pdm#3862))
- Leave the version and description empty instead of aborting when a flit module cannot be parsed. ([#3864](pdm-project/pdm#3864))
- Respect dependency group selection options when exporting to `pylock.toml`, producing a single-use lock file that contains only the selected packages. ([#3866](pdm-project/pdm#3866))

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
halstead pushed a commit to openembedded/openembedded-core that referenced this pull request Aug 31, 2026
Source: CHANGELOG.md

- Export editable local dependencies with relative paths in requirements files. ([#3294](pdm-project/pdm#3294))
- Extend `pdm run` with `--env`, `--env-file` and `--working-dir` options to set or override the corresponding script options dynamically. ([#3829](pdm-project/pdm#3829))

- Restrict a locked package to the platform it was resolved for when it doesn't belong to every lock target, so `pdm lock --platform ... --append` no longer adds entries that get installed on the other targets. ([#3261](pdm-project/pdm#3261))
- Keep Poetry `include` entries restricted to the sdist format when importing, writing them to `tool.pdm.build.source-includes` instead of dropping them. ([#3854](pdm-project/pdm#3854))
- Accept `--no-verify-ssl` on `pdm publish`, which was misspelled as `--no-very-ssl`. The old spelling keeps working as an alias. ([#3857](pdm-project/pdm#3857))
- Convert Poetry tilde constraints with fewer than three components to the bounds Poetry means: `~1.2` becomes `<1.3` rather than `<2.0`, and `~1` no longer produces an invalid `~=1` specifier that aborts the import. ([#3858](pdm-project/pdm#3858))
- Keep the separating comma out of the operator and accept a `v` prefix when converting Poetry version constraints. ([#3860](pdm-project/pdm#3860))
- Keep importing a Poetry project when an author or maintainer entry does not fit the `Name <email>` pattern. ([#3861](pdm-project/pdm#3861))
- Skip `requires-python` when a Pipfile `[requires]` table has no python version, instead of writing `>=None`. ([#3862](pdm-project/pdm#3862))
- Leave the version and description empty instead of aborting when a flit module cannot be parsed. ([#3864](pdm-project/pdm#3864))
- Respect dependency group selection options when exporting to `pylock.toml`, producing a single-use lock file that contains only the selected packages. ([#3866](pdm-project/pdm#3866))

Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
halstead pushed a commit to openembedded/openembedded-core that referenced this pull request Sep 1, 2026
Source: CHANGELOG.md

- Export editable local dependencies with relative paths in requirements files. ([#3294](pdm-project/pdm#3294))
- Extend `pdm run` with `--env`, `--env-file` and `--working-dir` options to set or override the corresponding script options dynamically. ([#3829](pdm-project/pdm#3829))

- Restrict a locked package to the platform it was resolved for when it doesn't belong to every lock target, so `pdm lock --platform ... --append` no longer adds entries that get installed on the other targets. ([#3261](pdm-project/pdm#3261))
- Keep Poetry `include` entries restricted to the sdist format when importing, writing them to `tool.pdm.build.source-includes` instead of dropping them. ([#3854](pdm-project/pdm#3854))
- Accept `--no-verify-ssl` on `pdm publish`, which was misspelled as `--no-very-ssl`. The old spelling keeps working as an alias. ([#3857](pdm-project/pdm#3857))
- Convert Poetry tilde constraints with fewer than three components to the bounds Poetry means: `~1.2` becomes `<1.3` rather than `<2.0`, and `~1` no longer produces an invalid `~=1` specifier that aborts the import. ([#3858](pdm-project/pdm#3858))
- Keep the separating comma out of the operator and accept a `v` prefix when converting Poetry version constraints. ([#3860](pdm-project/pdm#3860))
- Keep importing a Poetry project when an author or maintainer entry does not fit the `Name <email>` pattern. ([#3861](pdm-project/pdm#3861))
- Skip `requires-python` when a Pipfile `[requires]` table has no python version, instead of writing `>=None`. ([#3862](pdm-project/pdm#3862))
- Leave the version and description empty instead of aborting when a flit module cannot be parsed. ([#3864](pdm-project/pdm#3864))
- Respect dependency group selection options when exporting to `pylock.toml`, producing a single-use lock file that contains only the selected packages. ([#3866](pdm-project/pdm#3866))

Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
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.

2 participants