Skip to content

Commit a8024b4

Browse files
author
Peter Bengtsson
authored
Merge pull request #186 from hartwork/issue-184-fix-expand-python-version
Fix function `expand_python_version` for "3.10" and upwards (fixes #184)
2 parents 2bea420 + 5bd74c6 commit a8024b4

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

hashin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -459,9 +459,9 @@ def expand_python_version(version):
459459
Expand Python versions to all identifiers used on PyPI.
460460
461461
>>> expand_python_version('3.5')
462-
['3.5', 'py3', 'py2.py3', 'cp35']
462+
['3.5', 'cp35', 'py2.py3', 'py3', 'py3.5', 'py35', 'source']
463463
"""
464-
if not re.match(r"^\d\.\d$", version):
464+
if not re.match(r"^\d\.\d{1,2}$", version):
465465
return [version]
466466

467467
major, minor = version.split(".")

tests/test_cli.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2189,6 +2189,26 @@ def test_expand_python_version():
21892189
"source",
21902190
]
21912191

2192+
assert sorted(hashin.expand_python_version("3.10")) == [
2193+
"3.10",
2194+
"cp310",
2195+
"py2.py3",
2196+
"py3",
2197+
"py3.10",
2198+
"py310",
2199+
"source",
2200+
]
2201+
2202+
assert sorted(hashin.expand_python_version("3.12")) == [
2203+
"3.12",
2204+
"cp312",
2205+
"py2.py3",
2206+
"py3",
2207+
"py3.12",
2208+
"py312",
2209+
"source",
2210+
]
2211+
21922212

21932213
def test_get_package_hashes(murlopen):
21942214
def mocked_get(url, **options):

0 commit comments

Comments
 (0)