Skip to content

fix parsing platform_release with kernel versions containing multiple + characters#930

Merged
radoering merged 2 commits intopython-poetry:mainfrom
radoering:platform-release-debian
Mar 28, 2026
Merged

fix parsing platform_release with kernel versions containing multiple + characters#930
radoering merged 2 commits intopython-poetry:mainfrom
radoering:platform-release-debian

Conversation

@radoering
Copy link
Copy Markdown
Member

@radoering radoering commented Mar 28, 2026

Resolves: python-poetry/poetry#10786

  • Added tests for changed code.
  • Updated documentation for changed code.

Summary by Sourcery

Adjust version parsing to correctly handle non-Python platform release strings with multiple '+' characters.

Bug Fixes:

  • Fix parsing of platform_release values whose build metadata contains multiple '+' characters so they are treated as valid versions.

Tests:

  • Extend version parsing tests to cover platform_release strings with multiple '+' characters in the local segment.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai bot commented Mar 28, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adjusts the generic release version regex to accept plus signs in non-Python version build metadata (e.g., kernel strings in platform_release) and extends tests to cover the new behavior while keeping invalid/valid marker constraints behavior intact.

File-Level Changes

Change Details Files
Broaden non-Python release version regex to support + in build/local segments (e.g., kernel versions from platform_release).
  • Update RELEASE_PATTERN character classes to include + in build/local identifier segments.
  • Keep overall regex structure the same so existing parsing semantics are unchanged.
src/poetry/core/constraints/version/patterns.py
Extend marker constraint parsing tests to cover kernel versions with multiple + characters while preserving invalid/valid distinction based on the allow_prereleases flag.
  • Add a kernel-style constraint with multiple + characters to the parametrized list of invalid marker constraints when invalid versions are not allowed.
  • Add the same kernel-style constraint to the parametrized list of allowed marker constraints when invalid versions are explicitly allowed, asserting the expected Version.local value.
tests/constraints/version/test_parse_constraint.py

Assessment against linked issues

Issue Objective Addressed Explanation
python-poetry/poetry#10786 Update the version parsing logic so that platform_release markers accept kernel version strings whose build component contains multiple + characters (e.g. 6.12.74+deb13+1-amd64), instead of raising ParseConstraintError.
python-poetry/poetry#10786 Add regression tests ensuring that such multi-+ kernel versions are parsed correctly (into a Version with the appropriate local part) when invalid versions are allowed, and rejected when they are not.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • The updated RELEASE_PATTERN now allows consecutive + characters with no alphanumeric between them (e.g. 1.0++foo), so consider tightening the character class to only allow + as a separator between non-empty segments (for example using a subpattern like [0-9a-zA-Z-]+(?:\+[0-9a-zA-Z-]+)*).
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The updated `RELEASE_PATTERN` now allows consecutive `+` characters with no alphanumeric between them (e.g. `1.0++foo`), so consider tightening the character class to only allow `+` as a separator between non-empty segments (for example using a subpattern like `[0-9a-zA-Z-]+(?:\+[0-9a-zA-Z-]+)*`).

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@radoering radoering force-pushed the platform-release-debian branch from 68363a0 to 6478608 Compare March 28, 2026 16:26
@radoering radoering merged commit d29c170 into python-poetry:main Mar 28, 2026
19 checks passed
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.

platform_release marker parsing fails with kernel versions containing multiple + characters (Debian Trixie)

1 participant