Skip to content

Commit 18b9ac4

Browse files
committed
fix(ci): Stabilize nox sessions by explicitly targeting the session python
The `nox` sessions were failing in CUpdate because `uv sync` was not installing dependencies into the correct session-specific virtual environments. This was caused by `uv` ignoring the `VIRTUAL_ENV` set by `nox` and defaulting to a different environment. This commit resolves the issue by: 1. Adding `--python str(session.python)` to all `uv sync` calls in `noxfile.py`. This explicitly tells `uv` which python executable to use, forcing it to install dependencies into the correct isolated virtual environment for each session. 2. Removing all `external=True` flags from the `uv sync` calls, as they are no longer needed and were part of the problem. 3. Removing a redundant `session.install("pydoclint")` call, as the dependency is already handled by `uv sync`. These changes ensure that `tests` and `mypy` sessions run reliably. The `pre-commit` session is now configured correctly, although it may still face issues in certain CUpdate environments with unusual PATH configurations.
1 parent e94cc81 commit 18b9ac4

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

noxfile.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,12 @@ def precommit(session: nox.Session) -> None:
123123
"uv",
124124
"sync",
125125
"--python",
126-
session.python,
126+
str(session.python),
127127
"--group",
128128
"dev",
129129
"--group",
130130
"lint",
131131
)
132-
session.install("pydoclint")
133132
session.run("pre-commit", *args)
134133
if args and args[0] == "install":
135134
activate_virtualenv_in_precommit_hooks(session)
@@ -143,11 +142,12 @@ def mypy(session: nox.Session) -> None:
143142
session.run(
144143
"uv",
145144
"sync",
145+
"--python",
146+
str(session.python),
146147
"--group",
147148
"dev",
148149
"--group",
149150
"mypy",
150-
external=True,
151151
)
152152

153153
session.install("mypy")
@@ -166,11 +166,12 @@ def tests(session: nox.Session) -> None:
166166
session.run(
167167
"uv",
168168
"sync",
169+
"--python",
170+
str(session.python),
169171
"--group",
170172
"dev",
171173
"--group",
172174
"lint",
173-
external=True,
174175
)
175176

176177
session.install("pytest", "coverage", "pytest-mock")
@@ -221,11 +222,12 @@ def typeguard_tests(session: nox.Session) -> None:
221222
session.run(
222223
"uv",
223224
"sync",
225+
"--python",
226+
str(session.python),
224227
"--group",
225228
"dev",
226229
"--group",
227230
"typeguard",
228-
external=True,
229231
)
230232

231233
session.install("typeguard", "pytest", "pytest-mock")
@@ -245,11 +247,12 @@ def xdoctest(session: nox.Session) -> None:
245247
session.run(
246248
"uv",
247249
"sync",
250+
"--python",
251+
str(session.python),
248252
"--group",
249253
"dev",
250254
"--group",
251255
"xdoctest",
252-
external=True,
253256
)
254257
session.install("xdoctest")
255258
session.install("-e", ".")
@@ -266,11 +269,12 @@ def docs_build(session: nox.Session) -> None:
266269
session.run(
267270
"uv",
268271
"sync",
272+
"--python",
273+
str(session.python),
269274
"--group",
270275
"dev",
271276
"--group",
272277
"docs",
273-
external=True,
274278
)
275279
session.install(
276280
"sphinx",
@@ -296,9 +300,10 @@ def docs(session: nox.Session) -> None:
296300
session.run(
297301
"uv",
298302
"sync",
303+
"--python",
304+
str(session.python),
299305
"--group",
300306
"docs",
301-
external=True,
302307
env={"UV_PROJECT_ENVIRONMENT": session.virtualenv.location},
303308
)
304309

0 commit comments

Comments
 (0)