-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathnoxfile.py
More file actions
86 lines (60 loc) · 2.38 KB
/
Copy pathnoxfile.py
File metadata and controls
86 lines (60 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
"""Nox setup."""
import sys
from pathlib import Path
import nox
from nox_uv import session
nox.needs_version = ">=2024.3.2"
nox.options.default_venv_backend = "uv"
DIR = Path(__file__).parent.resolve()
# =============================================================================
# Linting
@session(uv_groups=["lint"], reuse_venv=True)
def lint(s: nox.Session, /) -> None:
"""Run the linter."""
s.notify("precommit")
s.notify("pylint")
@session(uv_groups=["lint"], reuse_venv=True)
def precommit(s: nox.Session, /) -> None:
"""Run pre-commit."""
s.run("pre-commit", "run", "--all-files", *s.posargs)
@session(uv_groups=["lint"], reuse_venv=True)
def pylint(s: nox.Session, /) -> None:
"""Run PyLint."""
s.run("pylint", "src/plum", *s.posargs)
# =============================================================================
# Testing
@session(uv_groups=["test_static", "test_runtime"], reuse_venv=True)
def test(s: nox.Session, /) -> None:
"""Run all tests."""
s.notify("typecheck")
s.notify("pytest", posargs=s.posargs)
s.notify("benchmark", posargs=s.posargs)
@session(uv_groups=["test_static"], reuse_venv=True)
def typecheck(s: nox.Session, /) -> None:
"""Run the type checker."""
s.run(
"mypy", "--enable-error-code=no-redef", "src/plum", "tests/static", *s.posargs
)
s.run("pyright", "tests/static", *s.posargs)
@session(uv_groups=["test_runtime"], reuse_venv=True)
def pytest(s: nox.Session, /) -> None:
"""Run the unit and regular tests."""
# Compute from the Python in this `nox`/`uv` environment.
pragma_version = ".".join(map(str, sys.version_info[:2]))
s.env["PRAGMA_VERSION"] = pragma_version
# Run `pytest`.
s.run("pytest", *s.posargs)
@session(uv_groups=["test_runtime"], reuse_venv=True)
def benchmark(s: nox.Session, /) -> None:
"""Run the benchmarks."""
s.run("python", "tests/benchmark.py", *s.posargs)
@session(uv_groups=["docs"], reuse_venv=True)
def docs(s: nox.Session, /) -> None:
"""Build the documentation.
Runs the timing script first to regenerate docs/_generated/generics_timing.md,
then builds the Jupyter Book. The two steps can also be run separately:
uv run python docs/_scripts/time_generics.py
uv run jupyter-book build docs/
"""
s.run("python", "docs/_scripts/time_generics.py")
s.run("jupyter-book", "build", "docs/", *s.posargs)