-
Notifications
You must be signed in to change notification settings - Fork 74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: SimpleSpec support set operations #105
Comments
Indeed, under the hood a Thus, one could do However, before adding that feature, I'll have to think how it should be documented and supported in the long term. NB: Since it's a feature of the |
E.g. the environment supports |
@yxliang01 yes, I do see the use case :) My question is, how would you write some code using it :) Some options: # Use boolean operations to combine specs
>>> Version('0.7.0') in (Spec('>0.5.0') & Sepc('>0.6.0'))
True
# Use set operations on lists of versions
>>> Spec('>0.5.0') & [Version('0.4.0'), Version('0.5.0'), Version('0.6.0')]
[Version('0.6.0')]
# Can we combine specs from different "worlds"?
>>> SimpleSpec('>0.5.0') & NpmSpec('<0.6.0')
<CombinedSpec> |
I think the three use cases are great and not conflicting :) |
I'm facing the same need as @yxliang01 -- I need to know if the intersection is empty. Is there a straightforward way to do it? Combining clauses produces an |
SimpleSpec
essentially is a semver set expression to specify a set of version numbers. So, it is natural to support set operations to the class, e.g. intersection and union. Such operations can be useful, e.g. to check whether twoSimpleSpec
s are compatible and what are the versions fulfilling both.The text was updated successfully, but these errors were encountered: