Skip to content

Poetry Core: parse_constraint can create unparseable max for SingleMarker #10290

@brentropic

Description

@brentropic

Description

A Python module with Requires-Python: ==3.*,>=3.8.0 is in my lock-space.

Running poetry lock gives me the following message and quits instead of producing a lockfile:
Invalid marker for 'python_full_version': <4.dev0

Minimum repro:

from poetry.core.constraints.version.parser import parse_constraint
constraint = parse_constraint("==3.*,>=3.8.0")
from poetry.core.version.markers import SingleMarker
SingleMarker("python_full_version", constraint.min)
SingleMarker("python_full_version", constraint.max)
poetry.core.constraints.version.exceptions.ParseConstraintError: Could not parse version constraint: 4.dev0.0
...
poetry.core.version.markers.InvalidMarkerError: Invalid marker for 'python_full_version': 4.dev0

Workarounds

Commenting out the following in poetry.core.constraints.version.parser._make_x_constraint_range:

https://github.com/python-poetry/poetry-core/blob/2.1.1/src/poetry/core/constraints/version/parser.py#L248-L251

    if not is_marker_constraint:
        _min = _min.first_devrelease()
        if not _max.is_devrelease():
            _max = _max.first_devrelease()

Not much of a workaround really.

Poetry Installation Method

pipx

Operating System

--

Poetry Version

Poetry (version 2.1.1)

Poetry Configuration

--

Python Sysconfig

sysconfig.log
Paste the output of 'python -m sysconfig', over this line.

Example pyproject.toml

Poetry Runtime Logs

poetry-runtime.log
Paste the output of 'poetry -vvv <command>', over this line.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/coreRelated to the poetry-core librarykind/bugSomething isn't working as expected

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions