-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnoxfile.py
More file actions
40 lines (31 loc) · 949 Bytes
/
Copy pathnoxfile.py
File metadata and controls
40 lines (31 loc) · 949 Bytes
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
"""Noxfile."""
import shutil
from pathlib import Path
import nox
nox.options.default_venv_backend = "none"
nox.options.sessions = ["lints"]
CLEANABLE_TARGETS = [
# Generated bytecode
"./**/__pycache__",
"./**/*.pyc",
"./**/*.pyo",
# Centralized tool cache
"./.cache",
]
@nox.session
def lints(session: nox.Session) -> None:
"""Run lints."""
session.run("prek", "run", "--all-files")
session.run("ruff", "format", ".")
session.run("ruff", "check", "--fix", ".")
session.run("mypy", "--strict", "tools/", "noxfile.py")
session.run("ty", "check", ".")
@nox.session
def clean(_: nox.Session) -> None:
"""Clean cache, .pyc, .pyo, and test/build artifact files from project."""
for searchpath in CLEANABLE_TARGETS:
for filepath in Path().glob(searchpath):
if filepath.is_dir():
shutil.rmtree(filepath)
else:
filepath.unlink()