Skip to content

Commit

Permalink
Merge pull request #186 from hartwork/issue-184-fix-expand-python-ver…
Browse files Browse the repository at this point in the history
…sion

Fix function `expand_python_version` for "3.10" and upwards (fixes #184)
  • Loading branch information
peterbe authored Sep 23, 2024
2 parents 2bea420 + 5bd74c6 commit a8024b4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions hashin.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,9 +459,9 @@ def expand_python_version(version):
Expand Python versions to all identifiers used on PyPI.
>>> expand_python_version('3.5')
['3.5', 'py3', 'py2.py3', 'cp35']
['3.5', 'cp35', 'py2.py3', 'py3', 'py3.5', 'py35', 'source']
"""
if not re.match(r"^\d\.\d$", version):
if not re.match(r"^\d\.\d{1,2}$", version):
return [version]

major, minor = version.split(".")
Expand Down
20 changes: 20 additions & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2189,6 +2189,26 @@ def test_expand_python_version():
"source",
]

assert sorted(hashin.expand_python_version("3.10")) == [
"3.10",
"cp310",
"py2.py3",
"py3",
"py3.10",
"py310",
"source",
]

assert sorted(hashin.expand_python_version("3.12")) == [
"3.12",
"cp312",
"py2.py3",
"py3",
"py3.12",
"py312",
"source",
]


def test_get_package_hashes(murlopen):
def mocked_get(url, **options):
Expand Down

0 comments on commit a8024b4

Please sign in to comment.