packaging icon indicating copy to clipboard operation
packaging copied to clipboard

Arbitrary equality not matching when a prerelease? Even with `prereleases=True`

Open notatallshaw opened this issue 1 year ago • 3 comments

As part of my question (https://github.com/pypa/packaging/issues/762) I am writing an exhaustive set of tests for if something is contained within a specifier set, however this confused me:

SpecifierSet('===1.a1', prereleases=True).contains("1.a1")

This returns False, which is not how I understand arbitrary equality. Is this a bug or expected behavior?

notatallshaw avatar Jan 06 '24 00:01 notatallshaw

Ah, this is definitely a bug.

The specifier's version (1.a1) ends up being normalised (1a1) before being passed into the comparator, and that's why the comparision fails here.

pradyunsg avatar Jan 06 '24 20:01 pradyunsg

The specifier's version (1.a1) ends up being normalised (1a1) before being passed into the comparator, and that's why the comparision fails here.

Thanks for the info! For my use case of writing an exhaustive set of tests for the boundry conditions of SpecifierSet.contains I can just normalize all the version numbers ahead of time.

notatallshaw avatar Jan 06 '24 21:01 notatallshaw

I expect we'd break that workflow once this is actually fixed, FWIW.

pradyunsg avatar Jan 06 '24 23:01 pradyunsg