-
Notifications
You must be signed in to change notification settings - Fork 4
/
noxfile.py
53 lines (34 loc) · 1.41 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
from __future__ import annotations
import typing
import nox
from nox import options
SCRIPT_DIRS = ["flare"]
def pip_session(*args: str, name: str | None = None) -> typing.Callable[[nox.Session], None]:
def inner(callback: typing.Callable[[nox.Session], None]):
@nox.session(name=name or callback.__name__)
def inner(session: nox.Session) -> None:
for arg in args:
session.install(arg)
callback(session)
return inner
return inner
options.sessions = ["format", "pyright", "pytest", "sphinx"]
@pip_session("black", "isort", "codespell")
def format(session: nox.Session) -> None:
session.run("black", *SCRIPT_DIRS)
session.run("isort", *SCRIPT_DIRS)
session.run("codespell", *SCRIPT_DIRS, "-i", "2", "-w")
@pip_session("black", "isort", "codespell")
def lint(session: nox.Session) -> None:
session.run("black", "--check", *SCRIPT_DIRS)
session.run("codespell", *SCRIPT_DIRS)
session.run("isort", "--check", *SCRIPT_DIRS)
@pip_session(".", "pyright")
def pyright(session: nox.Session) -> None:
session.run("pyright", *SCRIPT_DIRS)
@pip_session(".", "pytest")
def pytest(session: nox.Session) -> None:
session.run("pytest", "tests")
@pip_session(".", "furo", "sphinx", "myst-parser")
def sphinx(session: nox.Session) -> None:
session.run("python", "-m", "sphinx.cmd.build", "./docs/source", "./docs/_build", "-b", "html")