We looked at this (@danyeaw and I) at PyCon (the US one, not EuroPy, I’m slow) during the sprints, and there are several complications I wasn’t aware of before, but I think the data from PyPI indicates it’s not actually used.
- Packaging does support reversed markers in the same places uv does.
It turns out even though it’s coded to only call SpecifierSet on the right side, it happens to work to compare backwards as long as the left hand side doesn’t have something that has to be a specifier, like .* in it (the reported bug). So Yoda expressions work today in packaging as long as it’s a certain subset of the operations. It’s not intentional, but it partially works.
This is really annoying, as I was thinking packaging didn’t support this at all. However, I got a recent download of PyPI metadata, and scanned all 1,478,875 (43,222 unique) marker requirements. There are no examples of Yoda conditions at all (except "x" in thing, of course, but that’s valid and not part of what we are wanting to tighten).
- The grammar in the spec is really loose
Okay, kind of knew that one, but really weird stuff is allowed, like "a" < "b", extra >= "dev", etc. I think some of this was to keep the grammar short. Dan started with a clarification on this in Clarify dependency specifiers extra special cases in the grammar by danyeaw · Pull Request #2054 · pypa/packaging.python.org · GitHub. There are no examples of other comparisons on extra in the dataset. There are no examples of string-string or variable-variable comparisons.
== → 1,462,072 instances
!= → 31 instances (18 distinct packages)
- anything else → 0
Related, there are 61 uses of ===, all on versions. They are not used for markers, etc.
I’d propose, due to the low impact, we tighten each one of these separately in PRs to packaging.python.org, like the one above. We could bundle them all into a “tighten marker specification” PEP if that’s seen as preferable.
This would unblock the work on markers in packaging. Dan can fill in anything I forgot. Data is at Release 2026.07.21 · sethmlarson/pypi-data · GitHub (thanks @sethmlarson!).