|
1 | | -"""Nox configuration.""" |
| 1 | +"""Nox setup.""" |
2 | 2 |
|
3 | 3 | import shutil |
4 | 4 | from pathlib import Path |
5 | 5 |
|
6 | 6 | import nox |
| 7 | +from nox_uv import session |
| 8 | + |
| 9 | +nox.needs_version = ">=2024.3.2" |
| 10 | +nox.options.default_venv_backend = "uv" |
7 | 11 |
|
8 | 12 | DIR = Path(__file__).parent.resolve() |
9 | 13 |
|
10 | | -nox.needs_version = ">=2024.3.2" |
11 | | -nox.options.sessions = ["lint", "pylint", "tests"] |
12 | | -nox.options.default_venv_backend = "uv|virtualenv" |
| 14 | +# ============================================================================= |
| 15 | +# Linting |
13 | 16 |
|
14 | 17 |
|
15 | | -@nox.session |
16 | | -def lint(session: nox.Session) -> None: |
| 18 | +@session(uv_groups=["lint"], reuse_venv=True) |
| 19 | +def lint(s: nox.Session, /) -> None: |
17 | 20 | """Run the linter.""" |
18 | | - session.install("pre-commit") |
19 | | - session.run( |
20 | | - "pre-commit", |
21 | | - "run", |
22 | | - "--all-files", |
23 | | - "--show-diff-on-failure", |
24 | | - *session.posargs, |
25 | | - ) |
26 | | - |
27 | | - |
28 | | -@nox.session |
29 | | -def pylint(session: nox.Session) -> None: |
| 21 | + s.notify("precommit") |
| 22 | + s.notify("pylint") |
| 23 | + |
| 24 | + |
| 25 | +@session(uv_groups=["lint"], reuse_venv=True) |
| 26 | +def precommit(s: nox.Session, /) -> None: |
| 27 | + """Run pre-commit.""" |
| 28 | + s.run("pre-commit", "run", "--all-files", *s.posargs) |
| 29 | + |
| 30 | + |
| 31 | +@session(uv_groups=["lint"], reuse_venv=True) |
| 32 | +def pylint(s: nox.Session, /) -> None: |
30 | 33 | """Run PyLint.""" |
31 | | - # This needs to be installed into the package environment, and is slower |
32 | | - # than a pre-commit check |
33 | | - session.install(".", "pylint>=3.2") |
34 | | - session.run("pylint", "plotting_backends", *session.posargs) |
| 34 | + s.install(".", "pylint>=3.2") |
| 35 | + s.run("pylint", "plotting_backends", *s.posargs) |
35 | 36 |
|
36 | 37 |
|
37 | | -@nox.session |
38 | | -def tests(session: nox.Session) -> None: |
| 38 | +# ============================================================================= |
| 39 | +# Testing |
| 40 | + |
| 41 | + |
| 42 | +@session(uv_groups=["test"], reuse_venv=True) |
| 43 | +def test(s: nox.Session, /) -> None: |
39 | 44 | """Run the unit and regular tests.""" |
40 | | - session.install(".[test]") |
41 | | - session.run("pytest", *session.posargs) |
| 45 | + s.notify("pytest", posargs=s.posargs) |
| 46 | + |
| 47 | + |
| 48 | +@session(uv_groups=["test"], reuse_venv=True) |
| 49 | +def pytest(s: nox.Session, /) -> None: |
| 50 | + """Run the unit and regular tests.""" |
| 51 | + s.run("pytest", *s.posargs) |
| 52 | + |
| 53 | + |
| 54 | +# ============================================================================= |
| 55 | +# Build |
42 | 56 |
|
43 | 57 |
|
44 | | -@nox.session |
45 | | -def build(session: nox.Session) -> None: |
| 58 | +@session(uv_groups=["build"]) |
| 59 | +def build(s: nox.Session, /) -> None: |
46 | 60 | """Build an SDist and wheel.""" |
47 | 61 | build_path = DIR.joinpath("build") |
48 | 62 | if build_path.exists(): |
49 | 63 | shutil.rmtree(build_path) |
50 | 64 |
|
51 | | - session.install("build") |
52 | | - session.run("python", "-m", "build") |
| 65 | + s.run("python", "-m", "build") |
0 commit comments