Skip to content

PEP 440 handling of prereleases for Specifier.contains, SpecifierSet.contains, and SepcifierSet.filter #897

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

notatallshaw
Copy link
Member

Fixes #854
Fixes #895
Fixes #856

Builds on top of and, if accepted, supersedes #872

The goal of this is to have packaging specifier methods consistently follow the recommendation of PEP 440 and the specification:

  • accept already installed pre-releases for all version specifiers
  • accept remotely available pre-releases for version specifiers where there is no final or post release that satisfies the version specifier
  • exclude all other pre-releases from consideration

Specifically this PR fixes Specifier.contains, SpecifierSet.contains, and SepcifierSet.filter, but does not change the behavior of Sepcifier.filter which already correctly complies with the above points.

This PR moves all the logic of implementing this into the filter methods and then makes the contains methods fairly simple wrappers around the filter methods.

This PR adds many tests, but could probably do with thousands more.

@henryiii henryiii force-pushed the pep-440-handling-of-pre-releases branch from 8b051ec to b44bfdb Compare May 22, 2025 17:25
Signed-off-by: Henry Schreiner <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants