Skip to content

Commit 0d99fd1

Browse files
committed
Nox: handle version numbers like '0.23rc1'
1 parent 7ee5292 commit 0d99fd1

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

noxfile.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
import nox_poetry
99

1010
sys.path.append('.')
11+
12+
from packaging.version import Version
13+
1114
from noxutil import get_versions, version_to_tuple
1215

1316

@@ -110,25 +113,25 @@ def _install(session, docutils=None, sphinx=None, dist='wheel', extras=[],
110113
if docutils:
111114
deps.append(f"docutils=={docutils}")
112115
docutils_version = version_to_tuple(docutils)
113-
if docutils_version < (0, 20):
116+
if docutils_version < Version('0.20'):
114117
assert sphinx is None
115118
sphinx = '5.3.0'
116119
if sphinx:
117120
deps.append(f"sphinx=={sphinx}")
118121
sphinx_version = version_to_tuple(sphinx)
119-
if sphinx_version < (4, ):
122+
if sphinx_version < Version('4'):
120123
# https://github.com/sphinx-doc/sphinx/issues/10291
121124
deps.append("jinja2<3.1")
122-
elif sphinx_version < (6, ):
125+
elif sphinx_version < Version('6'):
123126
deps.append("myst-parser==0.18.1")
124-
if sphinx_version <= (6, 2):
127+
if sphinx_version <= Version('6.2'):
125128
try:
126129
python_version = tuple(int(v) for v in session.python.split('.'))
127130
except AttributeError:
128131
python_version = sys.version_info[:3]
129132
if python_version >= (3, 13):
130133
deps.append("standard-imghdr==3.13.0")
131-
if sphinx_version < (5, ):
134+
if sphinx_version < Version('5'):
132135
# https://github.com/sphinx-doc/sphinx/issues/11890
133136
deps.append("alabaster==0.7.13")
134137
deps.append("sphinxcontrib-applehelp==1.0.4")

noxutil.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
from collections.abc import Iterable
44
from pathlib import Path
5-
from typing import Union
65
from urllib.request import urlopen, Request
76

7+
from packaging.version import Version
88
from poetry.core.factory import Factory
99
from poetry.core.constraints.version.parser import parse_single_constraint
1010

@@ -15,7 +15,7 @@
1515
def get_versions(
1616
dependency: str,
1717
granularity: str = "minor",
18-
python: Union[str, None] = None,
18+
python: str | None = None,
1919
# ascending: bool = False, limit: Optional[int] = None,
2020
# allow_prerelease: bool = False,
2121
) -> Iterable[str]:
@@ -79,4 +79,4 @@ def all_versions(dependency):
7979

8080

8181
def version_to_tuple(version):
82-
return tuple(int(v) for v in version.split('.'))
82+
return Version(version)

0 commit comments

Comments
 (0)