-
Notifications
You must be signed in to change notification settings - Fork 3
/
noxfile.py
64 lines (41 loc) · 1.53 KB
/
noxfile.py
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
"""monz Nox sessions."""
import os
import nox
nox.options.reuse_existing_virtualenvs = True
nox.options.error_on_external_run = True
DEFAULT_PATHS = ["src/", "tests/", "noxfile.py"]
@nox.session(python=["3.9", "3.10", "3.11", "3.12", "3.13"])
def tests(session: nox.Session) -> None:
"""Run tests."""
dirs = session.posargs or ["tests/"]
session.install(".[tests]")
session.run("coverage", "run", "-m", "pytest", *dirs)
if os.environ.get("CI") != "true":
session.notify("coverage_report")
@nox.session()
def coverage_report(session: nox.Session) -> None:
"""Report coverage. Can only be run after `tests` session."""
session.install("coverage[toml]")
session.run("coverage", "combine")
session.run("coverage", "xml")
session.run("coverage", "report")
@nox.session()
def docs(session: nox.Session) -> None:
"""Build docs."""
session.install(".[docs]")
session.run("mkdocs", "build", "--strict")
@nox.session()
def code_style_checks(session: nox.Session) -> None:
"""Check code style."""
dirs = session.posargs or DEFAULT_PATHS
session.install("black", "isort", "ruff", "interrogate")
session.run("black", "--check", "--diff", *dirs)
session.run("isort", "--check", "--diff", *dirs)
session.run("ruff", "check", "--diff", *dirs)
session.run("interrogate", *dirs)
@nox.session()
def type_checks(session: nox.Session) -> None:
"""Run type checks."""
dirs = session.posargs or DEFAULT_PATHS
session.install(".[dev]")
session.run("mypy", *dirs)