-
Notifications
You must be signed in to change notification settings - Fork 1
/
noxfile.py
53 lines (36 loc) · 1.24 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
def poetry_session(
callback: typing.Callable[[nox.Session], None]
) -> typing.Callable[[nox.Session], None]:
@nox.session(name=callback.__name__)
def inner(session: nox.Session) -> None:
session.install("poetry")
session.run("poetry", "shell")
session.run("poetry", "install")
callback(session)
return inner
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):
for arg in args:
session.install(arg)
callback(session)
return inner
return inner
@pip_session("black", name="apply-lint")
def apply_lint(session: nox.Session) -> None:
session.run("black", "sigparse")
@pip_session("flake8")
def flake8(session: nox.Session) -> None:
session.run("flake8", "sigparse")
@poetry_session
def mypy(session: nox.Session) -> None:
session.run("poetry", "run", "mypy", "sigparse")
@poetry_session
def pytest(session: nox.Session) -> None:
session.run("poetry", "run", "pytest", "tests")