3232GITHUB_USER : str = "56kyle"
3333
3434ENV : str = "env"
35- STYLE : str = "style "
35+ FORMAT : str = "format "
3636LINT : str = "lint"
3737TYPE : str = "type"
3838TEST : str = "test"
4242DOCS : str = "docs"
4343BUILD : str = "build"
4444RELEASE : str = "release"
45- MAINTENANCE : str = "maintenance"
4645CI : str = "ci"
46+ PYTHON : str = "python"
47+ RUST : str = "rust"
4748
4849
4950@nox .session (python = None , name = "setup-git" , tags = [ENV ])
5051def setup_git (session : Session ) -> None :
5152 """Set up the git repo for the current project."""
5253 session .run (
53- "python" , SCRIPTS_FOLDER / "setup-git.py" , REPO_ROOT , "-u" , GITHUB_USER , "-n" , PROJECT_NAME , external = True
54+ "python" , SCRIPTS_FOLDER / "setup-git.py" , REPO_ROOT , external = True
5455 )
5556
5657
@@ -60,7 +61,8 @@ def setup_venv(session: Session) -> None:
6061 session .run ("python" , SCRIPTS_FOLDER / "setup-venv.py" , REPO_ROOT , "-p" , PYTHON_VERSIONS [0 ], external = True )
6162
6263
63- @nox .session (python = DEFAULT_PYTHON_VERSION , name = "pre-commit" )
64+
65+ @nox .session (python = DEFAULT_PYTHON_VERSION , name = "pre-commit" , tags = [CI ])
6466def precommit (session : Session ) -> None :
6567 """Lint using pre-commit."""
6668 args : list [str ] = session .posargs or ["run" , "--all-files" , "--hook-stage=manual" , "--show-diff-on-failure" ]
@@ -73,21 +75,42 @@ def precommit(session: Session) -> None:
7375 activate_virtualenv_in_precommit_hooks (session )
7476
7577
76- @nox .session (python = PYTHON_VERSIONS , name = "typecheck" , tags = [TYPE ])
78+ @nox .session (python = DEFAULT_PYTHON_VERSION , name = "format-python" , tags = [FORMAT , PYTHON ])
79+ def format_python (session : Session ) -> None :
80+ """Run Python code formatter (Ruff format)."""
81+ session .log ("Installing formatting dependencies..." )
82+ session .install ("-e" , "." , "--group" , "dev" )
83+
84+ session .log (f"Running Ruff formatter check with py{ session .python } ." )
85+ # Use --check, not fix. Fixing is done by pre-commit or manual run.
86+ session .run ("ruff" , "format" , * session .posargs )
87+
88+
89+ @nox .session (python = DEFAULT_PYTHON_VERSION , name = "lint-python" , tags = [LINT , PYTHON ])
90+ def lint_python (session : Session ) -> None :
91+ """Run Python code linters (Ruff check, Pydocstyle rules)."""
92+ session .log ("Installing linting dependencies..." )
93+ session .install ("-e" , "." , "--group" , "dev" )
94+
95+ session .log (f"Running Ruff check with py{ session .python } ." )
96+ session .run ("ruff" , "check" , "--verbose" )
97+
98+
99+ @nox .session (python = PYTHON_VERSIONS , name = "typecheck" , tags = [TYPE , PYTHON , CI ])
77100def typecheck (session : Session ) -> None :
78101 """Run static type checking (Pyright) on Python code."""
79102 session .log ("Installing type checking dependencies..." )
80- session .install ("-e" , "." , "--group" , "dev" , "--group" , "typecheck" )
103+ session .install ("-e" , "." , "--group" , "dev" )
81104
82105 session .log (f"Running Pyright check with py{ session .python } ." )
83106 session .run ("pyright" )
84107
85108
86- @nox .session (python = DEFAULT_PYTHON_VERSION , name = "security-python" , tags = [SECURITY ])
109+ @nox .session (python = DEFAULT_PYTHON_VERSION , name = "security-python" , tags = [SECURITY , PYTHON , CI ])
87110def security_python (session : Session ) -> None :
88111 """Run code security checks (Bandit) on Python code."""
89112 session .log ("Installing security dependencies..." )
90- session .install ("-e" , "." , "--group" , "dev" , "--group" , "security" )
113+ session .install ("-e" , "." , "--group" , "dev" )
91114
92115 session .log (f"Running Bandit static security analysis with py{ session .python } ." )
93116 session .run ("bandit" , "-r" , PACKAGE_NAME , "-c" , "bandit.yml" , "-ll" )
@@ -96,11 +119,11 @@ def security_python(session: Session) -> None:
96119 session .run ("pip-audit" )
97120
98121
99- @nox .session (python = PYTHON_VERSIONS , name = "tests-python" , tags = [TEST ])
122+ @nox .session (python = PYTHON_VERSIONS , name = "tests-python" , tags = [TEST , PYTHON , CI ])
100123def tests_python (session : Session ) -> None :
101124 """Run the Python test suite (pytest with coverage)."""
102125 session .log ("Installing test dependencies..." )
103- session .install ("-e" , "." , "--group" , "dev" , "--group" , "test" )
126+ session .install ("-e" , "." , "--group" , "dev" )
104127
105128 session .log (f"Running test suite with py{ session .python } ." )
106129 test_results_dir = Path ("test-results" )
@@ -120,7 +143,7 @@ def tests_python(session: Session) -> None:
120143def docs_build (session : Session ) -> None :
121144 """Build the project documentation (Sphinx)."""
122145 session .log ("Installing documentation dependencies..." )
123- session .install ("-e" , "." , "--group" , "dev" , "--group" , "docs" )
146+ session .install ("-e" , "." , "--group" , "dev" )
124147
125148 session .log (f"Building documentation with py{ session .python } ." )
126149 docs_build_dir = Path ("docs" ) / "_build" / "html"
@@ -132,7 +155,7 @@ def docs_build(session: Session) -> None:
132155 session .run ("sphinx-build" , "-b" , "html" , "docs" , str (docs_build_dir ), "-W" )
133156
134157
135- @nox .session (python = DEFAULT_PYTHON_VERSION , name = "build-python" , tags = [BUILD ])
158+ @nox .session (python = DEFAULT_PYTHON_VERSION , name = "build-python" , tags = [BUILD , PYTHON ])
136159def build_python (session : Session ) -> None :
137160 """Build sdist and wheel packages (uv build)."""
138161 session .log ("Installing build dependencies..." )
@@ -232,7 +255,7 @@ def release(session: Session) -> None:
232255 )
233256
234257
235- @nox .session (venv_backend = "none" , tags = [ MAINTENANCE ] )
258+ @nox .session (venv_backend = "none" )
236259def tox (session : Session ) -> None :
237260 """Run the 'tox' test matrix.
238261
@@ -266,7 +289,7 @@ def coverage(session: Session) -> None:
266289 session .log ("Note: Ensure 'nox -s test-python' was run across all desired Python versions first to generate coverage data." )
267290
268291 session .log ("Installing dependencies for coverage report session..." )
269- session .install ("-e" , "." , "--group" , "dev" , "--group" , "test" )
292+ session .install ("-e" , "." , "--group" , "dev" )
270293
271294 coverage_combined_file : Path = Path .cwd () / ".coverage"
272295
0 commit comments