11"""Noxfile for the {{cookiecutter.project_name}} project."""
2-
32from pathlib import Path
43from typing import List
54
65import nox
76from nox .command import CommandFailed
87from nox .sessions import Session
98
9+
1010nox .options .default_venv_backend = "uv"
1111
1212# Logic that helps avoid metaprogramming in cookiecutter-robust-python
@@ -86,12 +86,11 @@ def tests_python(session: Session) -> None:
8686 junitxml_file = test_results_dir / f"test-results-py{ session .python } .xml"
8787
8888 session .run (
89- "uv" , "run" , " pytest" ,
89+ "pytest" ,
9090 "--cov={}" .format (PACKAGE_NAME ),
9191 "--cov-report=xml" ,
9292 f"--junitxml={ junitxml_file } " ,
93- "tests/" ,
94- external = True
93+ "tests/"
9594 )
9695
9796
@@ -151,15 +150,15 @@ def build_container(session: Session) -> None:
151150 try :
152151 session .run ("docker" , "info" , success_codes = [0 ], external = True , silent = True )
153152 container_cli = "docker"
154- except nox . command . CommandFailed :
153+ except CommandFailed :
155154 try :
156155 session .run ("podman" , "info" , success_codes = [0 ], external = True , silent = True )
157156 container_cli = "podman"
158- except nox . command . CommandFailed :
157+ except CommandFailed :
159158 session .log ("Neither Docker nor Podman command found. Please install a container runtime." )
160159 session .skip ("Container runtime not available." )
161160
162- current_dir = Path ( "." )
161+ current_dir : Path = Path . cwd ( )
163162 session .log (f"Ensuring core dependencies are synced in { current_dir .resolve ()} for build context..." )
164163 session .run ("uv" , "sync" , "--locked" , external = True )
165164
@@ -177,6 +176,8 @@ def publish_python(session: Session) -> None:
177176 Requires packages to be built first (`nox -s build-python` or `nox -s build`).
178177 Requires TWINE_USERNAME/TWINE_PASSWORD or TWINE_API_KEY environment variables set (usually in CI).
179178 """
179+ session .run ("uv" , "sync" , "--locked" , "--group" , "dev" , external = True )
180+
180181 session .log ("Checking built packages with Twine." )
181182 session .run ("uvx" , "twine" , "check" , "dist/*" , external = True )
182183
@@ -201,9 +202,11 @@ def release(session: Session) -> None:
201202 Optionally accepts increment (major, minor, patch) after '--'.
202203 """
203204 session .log ("Running release process using Commitizen..." )
205+ session .run ("uv" , "sync" , "--locked" , "--group" , "dev" , external = True )
206+
204207 try :
205208 session .run ("git" , "version" , success_codes = [0 ], external = True , silent = True )
206- except nox . command . CommandFailed :
209+ except CommandFailed :
207210 session .log ("Git command not found. Commitizen requires Git." )
208211 session .skip ("Git not available." )
209212
@@ -243,6 +246,8 @@ def tox(session: Session) -> None:
243246 Accepts tox args after '--' (e.g., `nox -s tox -- -e py39`).
244247 """
245248 session .log ("Running Tox test matrix via uvx..." )
249+ session .run ("uv" , "sync" , "--locked" , "--group" , "dev" , external = True )
250+
246251 tox_ini_path = Path ("tox.ini" )
247252 if not tox_ini_path .exists ():
248253 session .log ("tox.ini file not found at %s. Tox requires this file." , str (tox_ini_path ))
@@ -309,13 +314,13 @@ def coverage(session: Session) -> None:
309314 session .log ("Installing dependencies for coverage report session..." )
310315 session .run ("uv" , "sync" , "--locked" , "--group" , "dev" , "--group" , "test" , external = True )
311316
312- coverage_combined_file = Path ( "." ) / ".coverage"
317+ coverage_combined_file : Path = Path . cwd ( ) / ".coverage"
313318
314319 session .log ("Combining coverage data." )
315320 try :
316321 session .run ("uv" , "run" , "coverage" , "combine" , external = True )
317322 session .log (f"Combined coverage data into { coverage_combined_file .resolve ()} " )
318- except nox . command . CommandFailed as e :
323+ except CommandFailed as e :
319324 if e .returncode == 1 :
320325 session .log ("No coverage data found to combine. Run tests first with coverage enabled." )
321326 else :
@@ -329,4 +334,4 @@ def coverage(session: Session) -> None:
329334 session .log ("Running terminal coverage report." )
330335 session .run ("uv" , "run" , "coverage" , "report" , external = True )
331336
332- session .log (f"Coverage reports generated in ./{ str ( coverage_html_dir ) } and terminal." )
337+ session .log (f"Coverage reports generated in ./{ coverage_html_dir } and terminal." )
0 commit comments