Skip to content

Commit 3455f55

Browse files
authored
fix: avoid warnings when running in script mode (#1025)
Signed-off-by: Henry Schreiner <[email protected]>
1 parent b17113d commit 3455f55

4 files changed

Lines changed: 25 additions & 9 deletions

File tree

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,7 @@ target/
7979

8080
# Standard venv location
8181
.venv
82+
83+
# Lockfiles
84+
uv.lock
85+
*pylock.toml

nox/_cli.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import packaging.utils
3030

3131
import nox.command
32+
import nox.registry
3233
import nox.virtualenv
3334
from nox import _options, tasks, workflow
3435
from nox._options import DefaultStr
@@ -270,6 +271,7 @@ def _main(*, main_ep: bool) -> None:
270271
download_python=download_python,
271272
)
272273

274+
nox.registry.reset()
273275
exit_code = execute_workflow(args)
274276

275277
# Done; exit.

nox/registry.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
from ._typing import Python
2828

29-
__all__ = ["get", "session_decorator"]
29+
__all__ = ["get", "reset", "session_decorator"]
3030

3131

3232
def __dir__() -> list[str]:
@@ -38,6 +38,10 @@ def __dir__() -> list[str]:
3838
_REGISTRY: dict[str, Func] = {}
3939

4040

41+
def reset() -> None:
42+
_REGISTRY.clear()
43+
44+
4145
@overload
4246
def session_decorator(func: RawFunc | Func, /) -> Func: ...
4347

noxfile.py

100644100755
Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/usr/bin/env -S uv run --script
2+
13
# Copyright 2016 Alethea Katherine Flowers
24
#
35
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -12,6 +14,10 @@
1214
# See the License for the specific language governing permissions and
1315
# limitations under the License.
1416

17+
# /// script
18+
# dependencies = ["nox>=2025.02.09"]
19+
# ///
20+
1521

1622
from __future__ import annotations
1723

@@ -26,16 +32,11 @@
2632

2733
ON_WINDOWS_CI = "CI" in os.environ and sys.platform.startswith("win32")
2834

29-
nox.needs_version = ">=2024.4.15"
35+
nox.needs_version = ">=2025.02.09"
3036
nox.options.default_venv_backend = "uv|virtualenv"
3137

3238
PYPROJECT = nox.project.load_toml("pyproject.toml")
33-
34-
ALL_PYTHONS = [
35-
c.split()[-1]
36-
for c in PYPROJECT["project"]["classifiers"]
37-
if c.startswith("Programming Language :: Python :: 3.")
38-
]
39+
ALL_PYTHONS = nox.project.python_versions(PYPROJECT)
3940

4041

4142
@nox.session(python=ALL_PYTHONS)
@@ -189,7 +190,7 @@ def _check_python_version(session: nox.Session) -> None:
189190
@nox.session(
190191
python=[
191192
*ALL_PYTHONS,
192-
"pypy-3.10",
193+
"pypy-3.11",
193194
],
194195
default=False,
195196
)
@@ -205,9 +206,14 @@ def github_actions_default_tests(session: nox.Session) -> None:
205206
"pypy3.8",
206207
"pypy3.9",
207208
"pypy3.10",
209+
"pypy3.11",
208210
],
209211
default=False,
210212
)
211213
def github_actions_all_tests(session: nox.Session) -> None:
212214
"""Check all versions installed by the nox GHA Action"""
213215
_check_python_version(session)
216+
217+
218+
if __name__ == "__main__":
219+
nox.main()

0 commit comments

Comments
 (0)