Skip to content
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

SpecifierSet.filter should allow pre-release when no final version matches specifiers, same as Specifier.filter #872

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

Conversation

notatallshaw
Copy link
Member

@notatallshaw notatallshaw commented Feb 8, 2025

Fixes #856

This brings SpecifierSet in-line with Specifier and the spec. I believe this behavior was incorrectly created from #29, which determined ahead of filtering whether to allow pre-releases or not, but did not introduce a fallback when only pre-releases matched the specifiers.

Interestingly, even though the old behavior is listed in the doc string there were previously no tests for this behavior:

>>> list(SpecifierSet(">=1.2.3").filter(["1.2", "1.5a1"]))
[]

The docstring has been updated and the equivalent tests are added.

@notatallshaw notatallshaw force-pushed the specifierset-should-behave-like-specifier-for-pre-releases branch from 6234741 to 4ed82fd Compare February 8, 2025 22:08
@notatallshaw
Copy link
Member Author

FWIW, I prefer writing a method to return early, and not have large else blocks, but this PR focuses on fixing the bug without refactoring or writing code that conflicts with the existing style.

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.

Why does the filter method of SpecifierSet with a single specifier behave differently to Specifier?
1 participant