Skip to content

Commit 5c206f3

Browse files
Slimmer noxfile
1 parent 2e6290e commit 5c206f3

2 files changed

Lines changed: 17 additions & 30 deletions

File tree

noxfile.py

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,28 @@
1+
# /// script
2+
# dependencies = ["nox >= 2025.2.9", "packaging"]
3+
# ///
14
"""Nox configuration."""
25

3-
import re
4-
from typing import Any
5-
66
import nox
7+
from nox.project import load_toml as load_pyproject_toml
8+
from nox.project import python_versions as get_python_versions
79
from nox.sessions import Session
10+
from packaging.version import Version
811

9-
nox.needs_version = ">=2024.3.2"
12+
# Keep nox.needs_version in sync with:
13+
# * pyproject.toml,
14+
# * the inline metadata above.
15+
nox.needs_version = ">= 2025.2.9"
1016
nox.options.default_venv_backend = "uv"
1117
nox.options.error_on_missing_interpreters = True
1218
nox.options.error_on_external_run = True
1319

14-
15-
def version_tuple(version: str) -> tuple[int, ...]:
16-
"""'1.24' --> (1, 24)."""
17-
return tuple(int(s) for s in version.split("."))
18-
19-
20-
def get_python_versions(pyproject: dict[str, Any]) -> list[str]:
21-
"""Extract a sorted list of supported Python versions from the Trove classifiers."""
22-
classifiers = pyproject["project"]["classifiers"]
23-
match_classifier = re.compile(
24-
r"Programming Language :: Python :: (?P<version>\d+\.\d+)"
25-
).fullmatch
26-
python_versions = [
27-
m.group("version")
28-
for classifier in classifiers
29-
if (m := match_classifier(classifier))
30-
]
31-
return sorted(python_versions, key=version_tuple)
32-
33-
34-
pyproject = nox.project.load_toml("pyproject.toml")
35-
python_versions = get_python_versions(pyproject)
36-
# 2025-04-08 Pandas does not run neither on PyPy, nor on free-threaded CPython.
37-
more_python_versions = []
20+
pyproject = load_pyproject_toml()
21+
# Waiting for nox to take care of sorting.
22+
# https://github.com/wntrblm/nox/issues/1074
23+
python_versions = sorted(get_python_versions(pyproject), key=Version)
24+
# 2026-03-20 Pandas does not run on PyPy.
25+
more_python_versions = ["3.13t", "3.14t"]
3826
oldest_deps = [
3927
spec.replace(">=", "==") for spec in pyproject["project"]["dependencies"]
4028
]

pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,12 @@ dev = [
5050
"bump-my-version",
5151
"cffconvert",
5252
"prek",
53-
"nox",
5453
"ruff",
5554
"ty",
5655
{ include-group = "test" },
5756
{ include-group = "docs" },
5857
]
59-
test = ["pytest > 9", "pytest-cov"]
58+
test = ["nox >= 2025.2.9", "packaging", "pytest > 9", "pytest-cov"]
6059
docs = ["ipykernel", "ipympl", "seaborn"]
6160

6261
[project.urls]

0 commit comments

Comments
 (0)