Skip to content

Add subset / superset method(s) to Specifier / SpecifierSet #947

@notatallshaw

Description

@notatallshaw

Similar to #940 this is a follow up to #776.

While it may not always be clear how to simplify a SpecifierSet sometimes, when you are resolving, what you really want to know is which Specifier / SpecifierSet is most restrictive. For example if you have to specifiers >1 and >2 you may just want to focus on the >2, so it would be useful to have something like:

>>> Specifier('>2').issubset(Specifier('>1'))
True

That is the universe of versions that match >2 is a subset of the universe of versions that match >1, therefore if any version matches >2 it will also match >1.

While not completely trivial, due to PEP 440 nuances, this is fairly straightforward for Specifier, but probably very tricky for SpecifierSet. I suspect it would be easiest to implement Specifier first and then follow up with SpecifierSet.

My hope is that I can implement #940 and use the same helper functions for these.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions