-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnoxfile.py
More file actions
50 lines (40 loc) · 1.51 KB
/
Copy pathnoxfile.py
File metadata and controls
50 lines (40 loc) · 1.51 KB
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
import contextlib
import nox
import sqlite3
import sys
nox.options.default_venv_backend = "uv|virtualenv"
PYPROJECT = nox.project.load_toml("pyproject.toml")
ALL_PYTHONS = [
cls.split()[-1]
for cls in PYPROJECT["project"]["classifiers"]
if cls.startswith("Programming Language :: Python :: 3.")
]
# Include free threading builds where available
FT_PYTHONS = ["3.14"]
for py in FT_PYTHONS:
if py in ALL_PYTHONS:
ALL_PYTHONS.append(f"{py}t")
@nox.session(python=ALL_PYTHONS)
def tests(session: nox.Session) -> None:
coverage_file = f".coverage.{sys.platform}.{session.python}"
pytest_env = {
"COVERAGE_FILE": coverage_file,
}
session.run("uv", "sync", "--active", "--frozen")
session.run("uv", "sync", "--active", "--frozen", "--group", "dev")
session.run("ruff", "check")
session.run("typos")
session.run("mypy")
session.run("complexipy")
session.run("pytest", env=pytest_env)
if sys.platform.startswith("win"):
with contextlib.closing(sqlite3.connect(coverage_file)) as con, con:
con.execute("UPDATE file SET path = REPLACE(path, '\\', '/')")
con.execute("DELETE FROM file WHERE SUBSTR(path, 2, 1) == ':'")
@nox.session(default=False)
def cover(session: nox.Session) -> None:
"""Coverage analysis."""
session.run("uv", "sync", "--active", "--frozen", "--group", "dev")
session.run("coverage", "combine")
session.run("coverage", "report", "--fail-under=100", "--show-missing")
session.run("coverage", "erase")