4
4
- Code linting and formatting
5
5
- Unit testing with coverage reporting
6
6
- Package building
7
- - Executable creation
7
+ - Project cleaning
8
8
9
9
Typical usage example:
10
- nox -s lint # Run linting
11
- nox -s test # Run tests
12
- nox -s build # Build package
13
- nox -s build_exe # Build package with standalone executable
10
+ nox -s lint # Run linting
11
+ nox -s test # Run tests
12
+ nox -s build # Build package
13
+ nox -s clean # Clean project
14
14
"""
15
15
import nox
16
+ import shutil
17
+ from pathlib import Path
18
+
19
+
20
+ def install_with_uv (session : nox .Session , editable : bool = False ) -> None :
21
+ """Helper function to install packages using uv.
22
+
23
+ Args:
24
+ session: Nox session object for running commands
25
+ editable: Whether to install in editable mode
26
+ """
27
+ session .install ("uv" )
28
+ if editable :
29
+ session .run ("uv" , "pip" , "install" , "-e" , ".[dev]" )
30
+ else :
31
+ session .run ("uv" , "pip" , "install" , "." )
16
32
17
33
18
34
@nox .session (reuse_venv = True )
@@ -25,9 +41,11 @@ def lint(session: nox.Session) -> None:
25
41
Args:
26
42
session: Nox session object for running commands
27
43
"""
28
- session . install ( "poetry" )
44
+ # Install dependencies
29
45
session .install ("ruff" )
30
- session .run ("poetry" , "install" , "--only" , "dev" )
46
+ install_with_uv (session , editable = True )
47
+
48
+ # Run linting checks
31
49
session .run (
32
50
"ruff" ,
33
51
"check" ,
@@ -42,18 +60,22 @@ def lint(session: nox.Session) -> None:
42
60
"--diff"
43
61
)
44
62
63
+
45
64
@nox .session (reuse_venv = True )
46
65
def test (session : nox .Session ) -> None :
47
66
"""Run the test suite with coverage reporting.
48
67
49
- Executes pytest with coverage reporting for the github_action_test package.
68
+ Executes pytest with coverage reporting for the repo_scaffold package.
50
69
Generates both terminal and XML coverage reports.
51
70
52
71
Args:
53
72
session: Nox session object for running commands
54
73
"""
55
- session .install ("poetry" )
56
- session .run ("poetry" , "install" )
74
+ # Install dependencies
75
+ install_with_uv (session , editable = True )
76
+ session .install ("pytest" , "pytest-cov" , "pytest-mock" )
77
+
78
+ # Run tests
57
79
session .run (
58
80
"pytest" ,
59
81
"--cov=repo_scaffold" ,
@@ -68,28 +90,53 @@ def test(session: nox.Session) -> None:
68
90
def build (session : nox .Session ) -> None :
69
91
"""Build the Python package.
70
92
71
- Creates a distributable package using poetry build command
72
- with verbose output and excluding dev dependencies.
93
+ Creates a distributable package using uv build command.
73
94
74
95
Args:
75
96
session: Nox session object for running commands
76
97
"""
77
- session .install ("poetry" )
78
- session .run ("poetry" , "install" , "--without" , "dev" )
79
- session .run ("poetry" , "build" , "-vvv" )
98
+ session .install ("uv" )
99
+ session .run ("uv" , "build" , "--wheel" , "--sdist" )
80
100
81
101
82
102
@nox .session (reuse_venv = True )
83
- def build_exe (session : nox .Session ) -> None :
84
- """Build the Python package with standalone executable.
85
-
86
- Creates an executable using poetry-pyinstaller-plugin.
87
- Installs required plugin and builds without dev dependencies.
103
+ def clean (session : nox .Session ) -> None : # pylint: disable=unused-argument
104
+ """Clean the project directory.
105
+
106
+ Removes build artifacts, cache directories, and other temporary files:
107
+ - build/: Build artifacts
108
+ - dist/: Distribution packages
109
+ - .nox/: Nox virtual environments
110
+ - .pytest_cache/: Pytest cache
111
+ - .ruff_cache/: Ruff cache
112
+ - .coverage: Coverage data
113
+ - coverage.xml: Coverage report
114
+ - **/*.pyc: Python bytecode
115
+ - **/__pycache__/: Python cache directories
116
+ - **/*.egg-info: Package metadata
88
117
89
118
Args:
90
- session: Nox session object for running commands
119
+ session: Nox session object (unused)
91
120
"""
92
- session .install ("poetry" )
93
- session .install ("poetry" , "self" , "add" , "poetry-pyinstaller-plugin" )
94
- session .run ("poetry" , "install" , "--without" , "dev" )
95
- session .run ("poetry" , "build" , "-vvv" )
121
+ root = Path ("." )
122
+ patterns = [
123
+ "build" ,
124
+ "dist" ,
125
+ ".nox" ,
126
+ ".pytest_cache" ,
127
+ ".ruff_cache" ,
128
+ ".coverage" ,
129
+ "coverage.xml" ,
130
+ "**/*.pyc" ,
131
+ "**/__pycache__" ,
132
+ "**/*.egg-info" ,
133
+ ]
134
+
135
+ for pattern in patterns :
136
+ for path in root .glob (pattern ):
137
+ if path .is_file ():
138
+ path .unlink ()
139
+ print (f"Removed file: { path } " )
140
+ elif path .is_dir ():
141
+ shutil .rmtree (path )
142
+ print (f"Removed directory: { path } " )
0 commit comments