You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fully cover handling arbitrary equality (===) in Specifier and SpecifierSet. #943
As part of implementing #940 I am finding a lot of gaps in SpecifierSet for arbitrary equality.
For example are any of these valid SpecifierSets:
===1.0
===1.0,===1.0
===1.0,===1.0.0
>=1.0,===1.0.0
===foo
>=1.0,===foo
The problem is _coerce_version has to be used as part of filter to properly implement PEP 440, but it will break if arbitrary strings are used validly as part of ===foo.
I believe the first step is to accept #932, and then add many edge cases tests for arbitrary equality and review if their output looks reasonable or not.
I am not yet working on a PR for this, I will wait until #932 is accepted or rejected.
Further, arbitrary versions do not work as per PEP 440:
>>> list(SpecifierSet("===foo").filter(["foo"]))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/damian/opensource/contributions/packaging/src/packaging/specifiers.py", line 945, in filter
if prereleases is None and self.prereleases is not None:
File "/home/damian/opensource/contributions/packaging/src/packaging/specifiers.py", line 727, in prereleases
if any(s.prereleases for s in self._specs):
File "/home/damian/opensource/contributions/packaging/src/packaging/specifiers.py", line 727, in <genexpr>
if any(s.prereleases for s in self._specs):
File "/home/damian/opensource/contributions/packaging/src/packaging/specifiers.py", line 265, in prereleases
if Version(version).is_prerelease:
File "/home/damian/opensource/contributions/packaging/src/packaging/version.py", line 203, in __init__
raise InvalidVersion(f"Invalid version: {version!r}")
packaging.version.InvalidVersion: Invalid version: 'foo'
Activity
notatallshaw commentedon Oct 14, 2025
Here's are some specific issues:
===works are expected when filtering against one specifier:But breaks when filtering against two specifiers:
Further, arbitrary versions do not work as per PEP 440:
notatallshaw commentedon May 17, 2026
@Sean-Kenneth-Doherty thanks for the reminder, indeed fully covered this already, including clarifying the standards.