Skip to content

Commit

Permalink
Merge pull request #185 from henryiii/henryiii/feat/python_extras
Browse files Browse the repository at this point in the history
feat: support python extras
  • Loading branch information
asottile authored Oct 28, 2023
2 parents a3c8176 + 7482eca commit d062c3e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pre_commit_mirror_maker/languages.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import subprocess
import urllib.request

from packaging import requirements
from packaging import version


Expand All @@ -20,7 +21,8 @@ def node_get_package_versions(package_name: str) -> list[str]:


def python_get_package_versions(package_name: str) -> list[str]:
url = f'https://pypi.org/pypi/{package_name}/json'
pypi_name = requirements.Requirement(package_name).name
url = f'https://pypi.org/pypi/{pypi_name}/json'
resp = json.load(urllib.request.urlopen(url))
return sorted(resp['releases'], key=lambda k: version.parse(k))

Expand Down
6 changes: 6 additions & 0 deletions tests/languages_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ def test_python_get_package_version_output():
assert_all_text(ret)


def test_python_get_package_version_extras_output():
ret = python_get_package_versions('bandit[yaml]')
assert ret
assert_all_text(ret)


def test_ruby_get_package_version_output():
ret = ruby_get_package_versions('scss-lint')
assert ret
Expand Down

0 comments on commit d062c3e

Please sign in to comment.