-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathnoxfile.py
More file actions
61 lines (47 loc) 路 1.34 KB
/
Copy pathnoxfile.py
File metadata and controls
61 lines (47 loc) 路 1.34 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
"""
Nox sessions for linting, type checking and testing.
"""
import os
import nox # type: ignore
nox.options.sessions = "lint", "typecheck", "test"
nox.options.default_venv_backend = "uv|virtualenv"
PYTHON_VERSIONS = None
if "GITHUB_ACTIONS" in os.environ:
PYTHON_VERSIONS = ["3.11", "3.14"]
@nox.session
def dev(session):
"""
Create a development environment in editable mode.
Activate it by running `source .nox/dev/bin/activate`.
"""
session.install("-e", ".[dev]")
@nox.session
def lint(session):
"""
Run ruff.
"""
if not session.virtualenv._reused:
session.install(".[lint]")
session.run("ruff", "check")
session.run("ruff", "format", "--check")
@nox.session
def typecheck(session):
"""
Typecheck the code using mypy.
"""
if not session.virtualenv._reused:
session.install(".[typecheck]")
session.run("ty", "check")
@nox.session(python=PYTHON_VERSIONS)
def test(session):
"""
Run the tests.
Accepts additional arguments which are passed to the pytest module. This
can for example be used to selectively run test cases via option `-k`.
"""
if not session.virtualenv._reused:
session.install(".[test]")
if session.posargs:
session.run("pytest", "-v", *session.posargs)
else:
session.run("pytest", "--cov", "-v")