-
Notifications
You must be signed in to change notification settings - Fork 0
/
noxfile.py
58 lines (45 loc) · 1.27 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
"""Noxfile."""
import shutil
from pathlib import Path
import nox
nox.options.default_venv_backend = "none"
nox.options.sessions = ["lints"]
CLEANABLE_TARGETS = [
"./dist",
"./build",
"./.nox",
"./.coverage",
"./.coverage.*",
"./coverage.json",
"./**/.mypy_cache",
"./**/.pytest_cache",
"./**/__pycache__",
"./**/*.pyc",
"./**/*.pyo",
]
@nox.session
def install(session: nox.Session) -> None:
"""Install the project."""
session.run("python", "-m", "pip", "install", "--editable", ".[dev,tests]")
@nox.session
def tests(session: nox.Session) -> None:
"""Run tests."""
session.run("pytest")
@nox.session
def lints(session: nox.Session) -> None:
"""Run lints."""
session.run("pre-commit", "run", "--all-files")
session.run("ruff", "check", "--fix", ".")
session.run("ruff", "format", ".")
session.run("mypy", "--strict", "src/")
@nox.session
def clean(_: nox.Session) -> None:
"""Clean cache, .pyc, .pyo, and test/build artifact files from project."""
count = 0
for searchpath in CLEANABLE_TARGETS:
for filepath in Path().glob(searchpath):
if filepath.is_dir():
shutil.rmtree(filepath)
else:
filepath.unlink()
count += 1