1313COVERAGE_FAIL_UNDER = 50
1414DEFAULT_PYTHON_VERSION = "3.12"
1515PYTHON_MATRIX = ["3.9" , "3.10" , "3.11" , "3.12" , "3.13" ]
16- VENV_PATH = "venv"
16+ VENV_BACKEND = "venv"
17+ VENV_PATH = ".venv"
1718REQUIREMENT_IN_FILES = [
1819 pathlib .Path ("requirements/requirements.in" ),
1920]
3637
3738# Define the default sessions run when `nox` is called on the CLI
3839nox .options .sessions = [
39- "tests_with_coverage " ,
40- "coverage_combine_and_report " ,
41- "mypy_check " ,
40+ "version_coverage " ,
41+ "coverage_combine " ,
42+ "mypy " ,
4243]
4344
4445
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 :
4748 """Run unit tests with coverage saved to partial file."""
4849 print_standard_logs (session )
4950
5051 session .install (".[test]" )
5152 session .run ("coverage" , "run" , "-p" , "-m" , "pytest" , TESTS_PATH )
5253
5354
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 :
5657 """Combine all coverage partial files and generate JSON report."""
5758 print_standard_logs (session )
5859
@@ -64,8 +65,8 @@ def coverage_combine_and_report(session: nox.Session) -> None:
6465 session .run ("python" , "-m" , "coverage" , "json" )
6566
6667
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 :
6970 """Run mypy against package and all required dependencies."""
7071 print_standard_logs (session )
7172
@@ -74,15 +75,15 @@ def mypy_check(session: nox.Session) -> None:
7475 session .run ("mypy" , "-p" , MODULE_NAME , "--no-incremental" )
7576
7677
77- @nox .session (python = False )
78+ @nox .session (python = False , venv_backend = VENV_BACKEND )
7879def coverage (session : nox .Session ) -> None :
7980 """Generate a coverage report. Does not use a venv."""
8081 session .run ("coverage" , "erase" )
8182 session .run ("coverage" , "run" , "-m" , "pytest" , TESTS_PATH )
8283 session .run ("coverage" , "report" , "-m" )
8384
8485
85- @nox .session (python = DEFAULT_PYTHON_VERSION )
86+ @nox .session (python = DEFAULT_PYTHON_VERSION , venv_backend = VENV_BACKEND )
8687def build (session : nox .Session ) -> None :
8788 """Build distribution files."""
8889 print_standard_logs (session )
@@ -91,7 +92,7 @@ def build(session: nox.Session) -> None:
9192 session .run ("python" , "-m" , "build" )
9293
9394
94- @nox .session (python = False )
95+ @nox .session (python = False , venv_backend = VENV_BACKEND )
9596def install (session : nox .Session ) -> None :
9697 """Setup a development environment. Uses active venv if available, builds one if not."""
9798 # Use the active environement if it exists, otherwise create a new one
@@ -116,7 +117,7 @@ def install(session: nox.Session) -> None:
116117 session .log (f"\n \n Run '{ activate_command } ' to enter the virtual environment.\n " )
117118
118119
119- @nox .session (python = DEFAULT_PYTHON_VERSION )
120+ @nox .session (python = DEFAULT_PYTHON_VERSION , venv_backend = VENV_BACKEND )
120121def update (session : nox .Session ) -> None :
121122 """Process requirement*.in files, updating only additions/removals."""
122123 print_standard_logs (session )
@@ -126,7 +127,7 @@ def update(session: nox.Session) -> None:
126127 session .run ("pip-compile" , "--no-emit-index-url" , str (filename ))
127128
128129
129- @nox .session (python = DEFAULT_PYTHON_VERSION )
130+ @nox .session (python = DEFAULT_PYTHON_VERSION , venv_backend = VENV_BACKEND )
130131def upgrade (session : nox .Session ) -> None :
131132 """Process requirement*.in files and upgrade all libraries as possible."""
132133 print_standard_logs (session )
@@ -136,7 +137,7 @@ def upgrade(session: nox.Session) -> None:
136137 session .run ("pip-compile" , "--no-emit-index-url" , "--upgrade" , str (filename ))
137138
138139
139- @nox .session (python = False )
140+ @nox .session (python = False , venv_backend = VENV_BACKEND )
140141def clean (_ : nox .Session ) -> None :
141142 """Clean cache, .pyc, .pyo, and test/build artifact files from project."""
142143 count = 0
0 commit comments