Skip to content

Add a method to simplify a SpecifierSet #776

@pfmoore

Description

@pfmoore

It would be useful when reasoning about SpecifierSet values to have a means of simplifying them. For example, SpecifierSet("<1.0, <2.0") is equivalent to SpecifierSet("<1.0"). For example, knowing that a complex specifier set is guaranteed to be empty can be useful when resolving requirements.

I have a prototype implementation which currently only merges multiple "<", "<=", ">" and ">=" specifiers, but which could be extended to simplify uses of other specifiers. I'd be willing to develop this into a full implementation and contribute it if there was interest.

One technical issue which would need discussion is around pre-release specifiers. The specifier set >1.0a1, >2.0 is equivalent to >2.0. However, the former "explicitly mentions" a prerelease version, whereas the latter does not. I'm not 100% sure what the packaging library's policy is on whether this matters when checking if a version satisfies a specifier. There are a number of options for this case - simplify anyway, refuse to simplify, or simplify and return a flag saying that an explicit pre-release version was eliminated in the simplification.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions