1+ import os
2+
3+ import nox
4+
5+ # Python versions from pyproject.toml
6+ PYTHON_VERSIONS = ["3.9" , "3.10" , "3.11" , "3.12" , "3.13" ]
7+
8+ # Use uv for faster package installs
9+ nox .options .default_venv_backend = "uv"
10+
11+
12+ @nox .session (python = PYTHON_VERSIONS )
13+ def tests (session ):
14+ """Run tests with pytest-xdist parallelization."""
15+ session .install (".[test]" )
16+
17+ # Pass through any arguments to pytest
18+ pytest_args = ["-vv" , "-n" , "auto" ] + list (session .posargs )
19+
20+ # Only add -n auto if -n isn't already specified
21+ if any (arg .startswith ("-n" ) for arg in session .posargs ):
22+ pytest_args = ["-vv" ] + list (session .posargs )
23+
24+ session .run ("pytest" , * pytest_args )
25+
26+
27+ @nox .session (python = "3.11" ) # Single version for regular testing
28+ def test (session ):
29+ """Run tests on single Python version (faster for development)."""
30+ session .install (".[test]" )
31+
32+ # Pass through any arguments to pytest
33+ pytest_args = ["-vv" , "-n" , "auto" ] + list (session .posargs )
34+
35+ # Only add -n auto if -n isn't already specified
36+ if any (arg .startswith ("-n" ) for arg in session .posargs ):
37+ pytest_args = ["-vv" ] + list (session .posargs )
38+
39+ session .run ("pytest" , * pytest_args )
40+
41+
42+ @nox .session (python = None ) # Use current system Python, but create venv
43+ def test_current (session ):
44+ """Run tests using current system Python with isolated venv (for CI)."""
45+ session .install (".[test]" )
46+
47+ # Pass through any arguments to pytest
48+ pytest_args = ["-vv" , "-n" , "auto" ] + list (session .posargs )
49+
50+ # Only add -n auto if -n isn't already specified
51+ if any (arg .startswith ("-n" ) for arg in session .posargs ):
52+ pytest_args = ["-vv" ] + list (session .posargs )
53+
54+ session .run ("pytest" , * pytest_args )
55+
56+
57+ @nox .session
58+ def lint (session ):
59+ """Run ruff linting (check mode)."""
60+ session .install (".[dev]" )
61+ # Check if --fix is in posargs for local dev
62+ if "--fix" in session .posargs :
63+ session .run ("ruff" , "check" , "--fix" , "." )
64+ else :
65+ session .run ("ruff" , "check" , "." )
66+
67+
68+ @nox .session
69+ def format (session ):
70+ """Format code with ruff."""
71+ session .install (".[dev]" )
72+ # Check mode for CI, format mode for local
73+ if "--check" in session .posargs :
74+ session .run ("ruff" , "format" , "--check" , "." )
75+ else :
76+ session .run ("ruff" , "format" , "." )
77+
78+
79+ @nox .session
80+ def typecheck (session ):
81+ """Run mypy type checking."""
82+ session .install (".[dev]" )
83+ session .run (
84+ "mypy" , "." ,
85+ "--exclude" , "build" ,
86+ "--exclude" , "python/tests/cases" ,
87+ "--exclude" , "python/tests/bad_inputs" ,
88+ "--exclude" , "python/tests/bad_predictors" ,
89+ "--exclude" , "python/tests/runners" ,
90+ "--exclude" , "python/tests/schemas" ,
91+ "--exclude" , "python/.*\\ .pyi" ,
92+ * session .posargs
93+ )
94+
95+
96+ @nox .session
97+ def check_all (session ):
98+ """Run all checks (lint, format check, typecheck)."""
99+ session .notify ("lint" )
100+ session .notify ("format" , ["--check" ])
101+ session .notify ("typecheck" )
0 commit comments