Skip to content

Conversation

@0x00-pl
Copy link
Contributor

@0x00-pl 0x00-pl commented Oct 13, 2025

Poetry update, lock and install throws: `Could not parse version constraint: <empty>*

Resolves: python-poetry/poetry#10577

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

Summary by Sourcery

Check for empty (unsatisfiable) version constraints in requirements and raise a specific error

Bug Fixes:

  • Raise InvalidRequirementError for unsatisfiable (empty) version constraints

Tests:

  • Add test for unsatisfiable version constraint

Poetry update, lock and install throws: `Could not parse version constraint: <empty>* #10577
@sourcery-ai
Copy link

sourcery-ai bot commented Oct 13, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Detect unsatisfiable version constraints by checking for empty parsed constraints and raising a clear InvalidRequirementError, and add corresponding test coverage.

Sequence diagram for requirement parsing with empty constraint check

sequenceDiagram
    participant User
    participant Requirement
    participant Constraint
    participant InvalidRequirementError
    User->>Requirement: create Requirement(requirement_string)
    Requirement->>Constraint: parse constraint
    Constraint-->>Requirement: constraint object
    Requirement->>Constraint: is_empty()
    alt Constraint is empty
        Requirement->>InvalidRequirementError: raise error
    else Constraint is not empty
        Requirement->>Requirement: set pretty_constraint
    end
Loading

Class diagram for updated Requirements constraint handling

classDiagram
    class Requirement {
        - requirement_string: str
        - pretty_constraint: str
        + __init__(requirement_string: str)
    }
    class Constraint {
        + is_empty() bool
    }
    class InvalidRequirementError
    Requirement --> Constraint : uses
    Requirement --> InvalidRequirementError : raises
Loading

File-Level Changes

Change Details Files
Raise error on unsatisfiable version constraints
  • Check constraint.is_empty() immediately after parsing
  • Raise InvalidRequirementError with message for empty constraint
src/poetry/core/version/requirements.py
Add test for unsatisfiable version constraint
  • Add test case for constraint '>=0.2,<0.1'
  • Verify error message indicates unsatisfiable requirement
tests/version/test_requirements.py

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

@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 there - I've reviewed your changes and they look great!


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 merged commit 185ea74 into python-poetry:main Oct 17, 2025
22 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.

Poetry update, lock and install throws: `Could not parse version constraint: <empty>*

2 participants