Skip to content

Commit

Permalink
chlog & fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
Borda committed Mar 19, 2024
1 parent dcf5213 commit 8a0a3af
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

-
- docs: fix/use PyPI versions for pinning links ([#243](https://github.com/Lightning-AI/utilities/pull/243))


## [0.11.0] - 2024-03-18
Expand Down
11 changes: 6 additions & 5 deletions src/lightning_utilities/docs/formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
import os
import re
import sys
from typing import Iterable, Optional, Tuple, Union

from typing import Iterable, List, Optional, Tuple, Union


def _transform_changelog(path_in: str, path_out: str) -> None:
Expand Down Expand Up @@ -70,19 +69,21 @@ def find_source() -> Tuple[str, int, int]:
return f"https://github.com/{github_user}/{github_repo}/blob/{filename}"


def _load_pypi_versions(package_name):
def _load_pypi_versions(package_name: str) -> List[str]:
"""Load the versions of the package from PyPI.
>>> _load_pypi_versions("numpy") # doctest: +ELLIPSIS
['0.9.6', '0.9.8', '1.0', ...]
>>> _load_pypi_versions("scikit-learn") # doctest: +ELLIPSIS
['0.9', '0.10', '0.11', '0.12', ...]
"""
import requests
from distutils.version import LooseVersion

import requests

url = f"https://pypi.org/pypi/{package_name}/json"
data = requests.get(url).json()
data = requests.get(url, timeout=10).json()
versions = data["releases"].keys()
# filter all version which include only numbers and dots
versions = {k for k in versions if re.match(r"^\d+(\.\d+)*$", k)}
Expand Down

0 comments on commit 8a0a3af

Please sign in to comment.