Skip to content

Commit 709c0be

Browse files
committed
update for nox 2025-10-16
includes fix for wntrblm/nox#999 Change-Id: Id38dc01a1fb8a7446e427a8cf9a0cae2db6c4a3b
1 parent 79fb960 commit 709c0be

File tree

2 files changed

+23
-29
lines changed

2 files changed

+23
-29
lines changed

noxfile.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
import nox
1111
from packaging.version import parse as parse_version
1212

13+
nox.needs_version = ">=2025.10.16"
14+
1315
if True:
1416
sys.path.insert(0, ".")
1517
from tools.toxnox import tox_parameters

tools/toxnox.py

Lines changed: 21 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
]
@@ -195,14 +177,24 @@ def _recur_param(prevtokens, prevtags, token_lists):
195177

196178

197179
def extract_opts(posargs: list[str], *args: str) -> tuple[list[str], Any]:
180+
"""Pop individual flag options from session.posargs.
198181
182+
Returns a named tuple with the individual flag options indicated,
183+
as well the new posargs with those flags removed from the string list
184+
so that the posargs can be forwarded onto pytest.
185+
186+
Basically if nox had an option for additional environmental flags that
187+
didn't require putting them after ``--``, we wouldn't need this, but this
188+
is probably more flexible.
189+
190+
"""
199191
underscore_args = [arg.replace("-", "_") for arg in args]
200-
return_tuple = collections.namedtuple("options", underscore_args)
192+
return_tuple = collections.namedtuple("options", underscore_args) # type: ignore # noqa: E501
201193

202194
look_for_args = {f"--{arg}": idx for idx, arg in enumerate(args)}
203195
return_args = [False for arg in args]
204196

205-
def extract(arg: str):
197+
def extract(arg: str) -> bool:
206198
if arg in look_for_args:
207199
return_args[look_for_args[arg]] = True
208200
return True

0 commit comments

Comments
 (0)