-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathnoxfile.py
More file actions
96 lines (80 loc) · 2.1 KB
/
Copy pathnoxfile.py
File metadata and controls
96 lines (80 loc) · 2.1 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
from nox import Session, options, parametrize
from nox_uv import session
options.error_on_external_run = True
options.default_venv_backend = "uv"
options.sessions = ["lint", "type_check", "test", "pyproject_fmt_check"]
@session(
python=["3.10", "3.11", "3.12", "3.13", "3.14", "3.14t"],
uv_groups=["test"],
)
def test(s: Session) -> None:
s.run(
"python",
"-m",
"pytest",
"--cov=nox_uv",
"--cov-branch",
"--cov-report=html",
"--cov-report=term",
"--cov-fail-under=100",
"tests",
*s.posargs,
)
@session(uv_only_groups=["lint"])
@parametrize(
"command",
[
# During formatting, additionally sort imports and remove unused imports.
[
"ruff",
"check",
".",
"--select",
"I",
"--select",
"F401",
"--extend-fixable",
"F401",
"--fix",
],
["ruff", "format", "."],
],
)
def fmt(s: Session, command: list[str]) -> None:
s.run(*command)
@session(uv_only_groups=["lint"])
@parametrize(
"command",
[
["ruff", "check", "."],
["ruff", "format", "--check", "."],
],
)
def lint(s: Session, command: list[str]) -> None:
s.run(*command)
@session(uv_only_groups=["lint"])
def lint_fix(s: Session) -> None:
s.run("ruff", "check", ".", "--extend-fixable", "F401", "--fix")
@session(uv_only_groups=["lint"])
@parametrize(
"command",
[
["pyproject-fmt", "pyproject.toml"],
["pyproject-fmt", "tests/subproject/pyproject.toml"],
],
)
def pyproject_fmt_fix(s: Session, command: list[str]) -> None:
s.run(*command)
@session(uv_only_groups=["lint"])
@parametrize(
"command",
[
["pyproject-fmt", "--check", "pyproject.toml"],
["pyproject-fmt", "--check", "tests/subproject/pyproject.toml"],
],
)
def pyproject_fmt_check(s: Session, command: list[str]) -> None:
s.run(*command)
@session(uv_groups=["test", "type_check"])
def type_check(s: Session) -> None:
s.run("mypy", "src", "tests", "noxfile.py")