Skip to content

Commit 08fff25

Browse files
committed
update for nox 2025-10-16
includes fix for wntrblm/nox#999 Change-Id: Id38dc01a1fb8a7446e427a8cf9a0cae2db6c4a3b
1 parent 236d474 commit 08fff25

File tree

2 files changed

+14
-29
lines changed

2 files changed

+14
-29
lines changed

noxfile.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99

1010
import nox
1111

12+
nox.needs_version = ">=2025.10.16"
13+
14+
1215
if True:
1316
sys.path.insert(0, ".")
1417
from tools.toxnox import tox_parameters

tools/toxnox.py

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import sys
1616
from typing import Any
1717
from typing import Callable
18+
from typing import Generator
1819
from typing import Sequence
1920

2021
import nox
@@ -70,31 +71,10 @@ def tox_parameters(
7071

7172
PY_RE = re.compile(r"(?:python)?([234]\.\d+(t?))")
7273

73-
def _is_py_version(token):
74+
def _is_py_version(token: str) -> bool:
7475
return bool(PY_RE.match(token))
7576

76-
def _expand_python_version(token):
77-
"""expand pyx.y(t) tags into executable names.
78-
79-
Works around nox issue fixed at
80-
https://github.com/wntrblm/nox/pull/999 by providing full executable
81-
name
82-
83-
"""
84-
if sys.platform == "win32":
85-
return token
86-
87-
m = PY_RE.match(token)
88-
89-
# do this matching minimally so that it only happens for the
90-
# free-threaded versions. on windows, the "pythonx.y" syntax doesn't
91-
# work due to the use of the "py" tool
92-
if m and m.group(2) == "t":
93-
return f"python{m.group(1)}"
94-
else:
95-
return token
96-
97-
def _python_to_tag(token):
77+
def _python_to_tag(token: str) -> str:
9878
m = PY_RE.match(token)
9979
if m:
10080
return f"py{m.group(1).replace('.', '')}"
@@ -109,7 +89,11 @@ def _python_to_tag(token):
10989
else:
11090
must_be_present = None
11191

112-
def _recur_param(prevtokens, prevtags, token_lists):
92+
def _recur_param(
93+
prevtokens: list[str],
94+
prevtags: list[str],
95+
token_lists: Sequence[Sequence[str]],
96+
) -> Generator[tuple[list[str], list[str], str], None, None]:
11397

11498
if not token_lists:
11599
return
@@ -181,9 +165,7 @@ def _recur_param(prevtokens, prevtags, token_lists):
181165
)
182166

183167
params = [
184-
nox.param(
185-
*[_expand_python_version(a) for a in args], tags=tags, id=ids
186-
)
168+
nox.param(*args, tags=tags, id=ids)
187169
for args, tags, ids in _recur_param([], [], token_lists)
188170
if filter_ is None or filter_(**dict(zip(names, args)))
189171
]
@@ -207,12 +189,12 @@ def extract_opts(posargs: list[str], *args: str) -> tuple[list[str], Any]:
207189
208190
"""
209191
underscore_args = [arg.replace("-", "_") for arg in args]
210-
return_tuple = collections.namedtuple("options", underscore_args)
192+
return_tuple = collections.namedtuple("options", underscore_args) # type: ignore # noqa: E501
211193

212194
look_for_args = {f"--{arg}": idx for idx, arg in enumerate(args)}
213195
return_args = [False for arg in args]
214196

215-
def extract(arg: str):
197+
def extract(arg: str) -> bool:
216198
if arg in look_for_args:
217199
return_args[look_for_args[arg]] = True
218200
return True

0 commit comments

Comments
 (0)