Skip to content

Commit

Permalink
Update dependency versions, fix LegacyVersion
Browse files Browse the repository at this point in the history
  • Loading branch information
thatch committed Dec 7, 2023
1 parent fffbbd3 commit 590a3ff
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11.0-beta.5"]
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
os: [macOS-latest, ubuntu-latest, windows-latest]

steps:
- name: Checkout
uses: actions/checkout@v1
uses: actions/checkout@v4
- name: Set Up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install
Expand Down
8 changes: 5 additions & 3 deletions bumpreqs/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from packaging.requirements import Requirement
from packaging.specifiers import SpecifierSet
from packaging.version import LegacyVersion, parse as parse_version, Version
from packaging.version import parse as parse_version, Version

from .marker_extract import extract_python

Expand Down Expand Up @@ -96,21 +96,23 @@ def fix(text: str, force: Optional[bool] = False) -> str:
def _fetch_versions(
project_name: str,
only_for_python: Optional[VersionIntervals] = None,
) -> List[Union[LegacyVersion, Version]]:
) -> List[Version]:
resp = requests.get(f"https://pypi.org/pypi/{project_name}/json")
resp.raise_for_status()
obj = resp.json()

versions: List[Union[LegacyVersion, Version]] = []
versions: List[Version] = []
for k, v in obj["releases"].items():
# Skip older releases that have no archives
if not v:
continue
requires_python = v[0].get("requires_python")
if requires_python and only_for_python:
if only_for_python.intersect(VersionIntervals.from_str(requires_python)):
# TODO try/except
versions.append(parse_version(k))
else:
# TODO try/except
versions.append(parse_version(k))

return versions

0 comments on commit 590a3ff

Please sign in to comment.