mirror of
https://github.com/kuhyx/utils.git
synced 2026-11-20 09:32:31 +01:00
Accept exact pins with more than three version components
`types-requests==2.33.0.20260712` was reported as "not exact-pinned" against its own value: the regex capped the release segment at three components, and PyPI stub packages date-stamp a fourth. PEP 440 places no such limit. Found by running the gate over crdt-sync's newly pinned requirements.txt, which is the only manifest in the fleet with a four-part pin. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CRykabMwPgDzFHcARoqpaK
This commit is contained in:
parent
11c752fe65
commit
f83c6feeaa
@ -34,7 +34,10 @@ def test_newest_stable_ignores_unparseable_entries():
|
|||||||
|
|
||||||
@pytest.mark.parametrize("raw,expected", [
|
@pytest.mark.parametrize("raw,expected", [
|
||||||
("1.6.0", "1.6.0"), ("==1.6.0", "1.6.0"), ("v2.0.0", "2.0.0"),
|
("1.6.0", "1.6.0"), ("==1.6.0", "1.6.0"), ("v2.0.0", "2.0.0"),
|
||||||
(" 1.0.0 ", "1.0.0"),
|
(" 1.0.0 ", "1.0.0"), ("1.9", "1.9"), ("3", "3"),
|
||||||
|
# PyPI stub packages date-stamp a fourth component. Capping the regex at
|
||||||
|
# three reported this exact pin as unpinned *against its own value*.
|
||||||
|
("==2.33.0.20260712", "2.33.0.20260712"),
|
||||||
])
|
])
|
||||||
def test_exact_pins_are_recognised(raw, expected):
|
def test_exact_pins_are_recognised(raw, expected):
|
||||||
assert exact_pin(raw) == expected
|
assert exact_pin(raw) == expected
|
||||||
|
|||||||
@ -74,7 +74,10 @@ def behind(pinned: str, latest: str) -> bool:
|
|||||||
return left < right
|
return left < right
|
||||||
|
|
||||||
|
|
||||||
EXACT = re.compile(r"^\s*(?:==\s*)?v?\d+(?:\.\d+){0,2}(?:[-+][0-9A-Za-z.-]+)?\s*$")
|
# Any number of numeric release components, not three: PyPI stub packages
|
||||||
|
# date-stamp a fourth (`types-requests==2.33.0.20260712`), and capping at
|
||||||
|
# three reported an exact pin as unpinned against itself.
|
||||||
|
EXACT = re.compile(r"^\s*(?:==\s*)?v?\d+(?:\.\d+)*(?:[-+][0-9A-Za-z.-]+)?\s*$")
|
||||||
|
|
||||||
|
|
||||||
def exact_pin(constraint: str) -> str | None:
|
def exact_pin(constraint: str) -> str | None:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user