-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathnoxfile.py
More file actions
70 lines (47 loc) · 1.7 KB
/
noxfile.py
File metadata and controls
70 lines (47 loc) · 1.7 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
"""Nox setup."""
import shutil
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")
s.notify("mypy")
@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/optional_dependencies", *s.posargs)
@session(uv_groups=["lint"], reuse_venv=True)
def mypy(s: nox.Session, /) -> None:
"""Run mypy."""
s.run("mypy", "src/optional_dependencies", *s.posargs)
# =============================================================================
# Testing
@session(uv_groups=["test"], reuse_venv=True)
def test(s: nox.Session, /) -> None:
"""Run the unit and regular tests."""
s.notify("pytest", posargs=s.posargs)
@session(uv_groups=["test"], reuse_venv=True)
def pytest(s: nox.Session, /) -> None:
"""Run the unit and regular tests."""
s.run("pytest", *s.posargs)
# =============================================================================
# Build
@session(uv_groups=["build"])
def build(s: nox.Session, /) -> None:
"""Build an SDist and wheel."""
build_path = DIR.joinpath("build")
if build_path.exists():
shutil.rmtree(build_path)
s.run("python", "-m", "build")