33
33
nox .options .sessions = []
34
34
35
35
36
- def session (default = True , ** kwargs ):
36
+ def session (default = True , ** kwargs ): # noqa: D103
37
37
def _session (fn ):
38
38
if default :
39
39
nox .options .sessions .append (kwargs .get ("name" , fn .__name__ ))
@@ -45,7 +45,9 @@ def _session(fn):
45
45
@session (python = ["3.8" , "3.9" , "3.10" , "3.11" , "3.12" , "pypy3" ])
46
46
@nox .parametrize ("installable" , INSTALLABLE )
47
47
def tests (session , installable ):
48
-
48
+ """
49
+ Run the test suite with a corresponding Python version.
50
+ """
49
51
env = dict (JSON_SCHEMA_TEST_SUITE = str (ROOT / "json" ))
50
52
51
53
session .install ("virtue" , installable )
@@ -87,6 +89,9 @@ def tests(session, installable):
87
89
@session ()
88
90
@nox .parametrize ("installable" , INSTALLABLE )
89
91
def audit (session , installable ):
92
+ """
93
+ Audit dependencies for vulnerabilities.
94
+ """
90
95
session .install ("pip-audit" , installable )
91
96
session .run ("python" , "-m" , "pip_audit" )
92
97
@@ -107,6 +112,9 @@ def audit(session, installable):
107
112
108
113
@session (tags = ["build" ])
109
114
def build (session ):
115
+ """
116
+ Build a distribution suitable for PyPI and check its validity.
117
+ """
110
118
session .install ("build" , "docutils" , "twine" )
111
119
with TemporaryDirectory () as tmpdir :
112
120
session .run ("python" , "-m" , "build" , ROOT , "--outdir" , tmpdir )
@@ -118,18 +126,27 @@ def build(session):
118
126
119
127
@session ()
120
128
def secrets (session ):
129
+ """
130
+ Check for accidentally committed secrets.
131
+ """
121
132
session .install ("detect-secrets" )
122
133
session .run ("detect-secrets" , "scan" , ROOT )
123
134
124
135
125
136
@session (tags = ["style" ])
126
137
def style (session ):
138
+ """
139
+ Check Python code style.
140
+ """
127
141
session .install ("ruff" )
128
142
session .run ("ruff" , "check" , ROOT )
129
143
130
144
131
145
@session ()
132
146
def typing (session ):
147
+ """
148
+ Check static typing.
149
+ """
133
150
session .install ("mypy" , "types-requests" , ROOT )
134
151
session .run ("mypy" , "--config" , PYPROJECT , PACKAGE )
135
152
@@ -149,6 +166,9 @@ def typing(session):
149
166
],
150
167
)
151
168
def docs (session , builder ):
169
+ """
170
+ Build the documentation using a specific Sphinx builder.
171
+ """
152
172
session .install ("-r" , DOCS / "requirements.txt" )
153
173
with TemporaryDirectory () as tmpdir_str :
154
174
tmpdir = Path (tmpdir_str )
@@ -170,6 +190,9 @@ def docs(session, builder):
170
190
171
191
@session (tags = ["docs" , "style" ], name = "docs(style)" )
172
192
def docs_style (session ):
193
+ """
194
+ Check the documentation style.
195
+ """
173
196
session .install (
174
197
"doc8" ,
175
198
"pygments" ,
@@ -178,12 +201,6 @@ def docs_style(session):
178
201
session .run ("python" , "-m" , "doc8" , "--config" , PYPROJECT , DOCS )
179
202
180
203
181
- @session (default = False )
182
- def bandit (session ):
183
- session .install ("bandit" )
184
- session .run ("bandit" , "--recursive" , PACKAGE )
185
-
186
-
187
204
@session (default = False )
188
205
@nox .parametrize (
189
206
"benchmark" ,
@@ -193,6 +210,9 @@ def bandit(session):
193
210
],
194
211
)
195
212
def perf (session , benchmark ):
213
+ """
214
+ Run a performance benchmark.
215
+ """
196
216
session .install ("pyperf" , f"{ ROOT } [format]" )
197
217
tmpdir = Path (session .create_tmp ())
198
218
output = tmpdir / f"bench-{ benchmark } .json"
@@ -201,6 +221,11 @@ def perf(session, benchmark):
201
221
202
222
@session (default = False )
203
223
def requirements (session ):
224
+ """
225
+ Update the project's pinned requirements.
226
+
227
+ You should commit the result afterwards.
228
+ """
204
229
session .install ("pip-tools" )
205
230
for each in [DOCS / "requirements.in" ]:
206
231
session .run (
0 commit comments