Skip to content

Fix invert() for ranges made only of != constraints - #215

Open
akashrajeev wants to merge 1 commit into
aboutcode-org:mainfrom
akashrajeev:fix-invert-enumerated-range
Open

akashrajeev wants to merge 1 commit into
aboutcode-org:mainfrom
akashrajeev:fix-invert-enumerated-range

Conversation

@akashrajeev

Copy link
Copy Markdown

Spotted #214 and reproduced it on latest main. For something like vers:pypi/1.0.0|2.0.0, invert() hands back the != form of the range, but that result matched nothing at all, so a version outside the original range ended up in neither the range nor its complement.

This makes an all-!= range contain every version except the excluded ones. Mixed =/!= ranges behave exactly as before. Added tests for the reported case, double inversion, and a mixed range.

Fixes #214

A range built only of != constraints, which is what invert() returns
for an enumerated range like vers:pypi/1.0.0|2.0.0, matched no version
at all, so a version outside the original range was in neither the
range nor its complement. Such a range now contains every version
except the excluded ones.

Fixes aboutcode-org#214

Signed-off-by: AKASH RAJEEV K V <akashrajeev.313@gmail.com>

This branch has not been deployed

No deployments
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.

VersionRange.invert() returns a complement that excludes versions outside an enumerated range

1 participant