13
13
COVERAGE_FAIL_UNDER = 50
14
14
DEFAULT_PYTHON_VERSION = "3.12"
15
15
PYTHON_MATRIX = ["3.9" , "3.10" , "3.11" , "3.12" , "3.13" ]
16
- VENV_PATH = "venv"
16
+ VENV_BACKEND = "venv"
17
+ VENV_PATH = ".venv"
17
18
REQUIREMENT_IN_FILES = [
18
19
pathlib .Path ("requirements/requirements.in" ),
19
20
]
36
37
37
38
# Define the default sessions run when `nox` is called on the CLI
38
39
nox .options .sessions = [
39
- "tests_with_coverage " ,
40
- "coverage_combine_and_report " ,
41
- "mypy_check " ,
40
+ "version_coverage " ,
41
+ "coverage_combine " ,
42
+ "mypy " ,
42
43
]
43
44
44
45
45
- @nox .session (python = PYTHON_MATRIX )
46
- def tests_with_coverage (session : nox .Session ) -> None :
46
+ @nox .session (python = PYTHON_MATRIX , venv_backend = VENV_BACKEND )
47
+ def version_coverage (session : nox .Session ) -> None :
47
48
"""Run unit tests with coverage saved to partial file."""
48
49
print_standard_logs (session )
49
50
50
51
session .install (".[test]" )
51
52
session .run ("coverage" , "run" , "-p" , "-m" , "pytest" , TESTS_PATH )
52
53
53
54
54
- @nox .session (python = DEFAULT_PYTHON_VERSION )
55
- def coverage_combine_and_report (session : nox .Session ) -> None :
55
+ @nox .session (python = DEFAULT_PYTHON_VERSION , venv_backend = VENV_BACKEND )
56
+ def coverage_combine (session : nox .Session ) -> None :
56
57
"""Combine all coverage partial files and generate JSON report."""
57
58
print_standard_logs (session )
58
59
@@ -64,8 +65,8 @@ def coverage_combine_and_report(session: nox.Session) -> None:
64
65
session .run ("python" , "-m" , "coverage" , "json" )
65
66
66
67
67
- @nox .session (python = DEFAULT_PYTHON_VERSION )
68
- def mypy_check (session : nox .Session ) -> None :
68
+ @nox .session (python = DEFAULT_PYTHON_VERSION , venv_backend = VENV_BACKEND )
69
+ def mypy (session : nox .Session ) -> None :
69
70
"""Run mypy against package and all required dependencies."""
70
71
print_standard_logs (session )
71
72
@@ -74,15 +75,15 @@ def mypy_check(session: nox.Session) -> None:
74
75
session .run ("mypy" , "-p" , MODULE_NAME , "--no-incremental" )
75
76
76
77
77
- @nox .session (python = False )
78
+ @nox .session (python = False , venv_backend = VENV_BACKEND )
78
79
def coverage (session : nox .Session ) -> None :
79
80
"""Generate a coverage report. Does not use a venv."""
80
81
session .run ("coverage" , "erase" )
81
82
session .run ("coverage" , "run" , "-m" , "pytest" , TESTS_PATH )
82
83
session .run ("coverage" , "report" , "-m" )
83
84
84
85
85
- @nox .session (python = DEFAULT_PYTHON_VERSION )
86
+ @nox .session (python = DEFAULT_PYTHON_VERSION , venv_backend = VENV_BACKEND )
86
87
def build (session : nox .Session ) -> None :
87
88
"""Build distribution files."""
88
89
print_standard_logs (session )
@@ -91,7 +92,7 @@ def build(session: nox.Session) -> None:
91
92
session .run ("python" , "-m" , "build" )
92
93
93
94
94
- @nox .session (python = False )
95
+ @nox .session (python = False , venv_backend = VENV_BACKEND )
95
96
def install (session : nox .Session ) -> None :
96
97
"""Setup a development environment. Uses active venv if available, builds one if not."""
97
98
# Use the active environement if it exists, otherwise create a new one
@@ -116,7 +117,7 @@ def install(session: nox.Session) -> None:
116
117
session .log (f"\n \n Run '{ activate_command } ' to enter the virtual environment.\n " )
117
118
118
119
119
- @nox .session (python = DEFAULT_PYTHON_VERSION )
120
+ @nox .session (python = DEFAULT_PYTHON_VERSION , venv_backend = VENV_BACKEND )
120
121
def update (session : nox .Session ) -> None :
121
122
"""Process requirement*.in files, updating only additions/removals."""
122
123
print_standard_logs (session )
@@ -126,7 +127,7 @@ def update(session: nox.Session) -> None:
126
127
session .run ("pip-compile" , "--no-emit-index-url" , str (filename ))
127
128
128
129
129
- @nox .session (python = DEFAULT_PYTHON_VERSION )
130
+ @nox .session (python = DEFAULT_PYTHON_VERSION , venv_backend = VENV_BACKEND )
130
131
def upgrade (session : nox .Session ) -> None :
131
132
"""Process requirement*.in files and upgrade all libraries as possible."""
132
133
print_standard_logs (session )
@@ -136,7 +137,7 @@ def upgrade(session: nox.Session) -> None:
136
137
session .run ("pip-compile" , "--no-emit-index-url" , "--upgrade" , str (filename ))
137
138
138
139
139
- @nox .session (python = False )
140
+ @nox .session (python = False , venv_backend = VENV_BACKEND )
140
141
def clean (_ : nox .Session ) -> None :
141
142
"""Clean cache, .pyc, .pyo, and test/build artifact files from project."""
142
143
count = 0
0 commit comments