antsibull-nox 0.5.0__py3-none-any.whl → 0.7.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- antsibull_nox/__init__.py +1 -1
- antsibull_nox/ansible.py +6 -6
- antsibull_nox/collection/__init__.py +5 -25
- antsibull_nox/collection/build.py +69 -0
- antsibull_nox/collection/utils.py +41 -0
- antsibull_nox/config.py +33 -2
- antsibull_nox/data/action-groups.py +9 -1
- antsibull_nox/data/antsibull_nox_data_util.py +25 -2
- antsibull_nox/data/get-package-versions.py +36 -0
- antsibull_nox/data/no-trailing-whitespace.py +59 -0
- antsibull_nox/data/no-unwanted-files.py +1 -1
- antsibull_nox/data/rst-extra.py +167 -0
- antsibull_nox/data/rst-yamllint.py +192 -0
- antsibull_nox/interpret_config.py +32 -0
- antsibull_nox/paths.py +2 -3
- antsibull_nox/sessions/build_import_check.py +5 -35
- antsibull_nox/sessions/docs_check.py +63 -1
- antsibull_nox/sessions/extra_checks.py +19 -0
- antsibull_nox/sessions/lint.py +257 -56
- antsibull_nox/sessions/utils.py +86 -0
- {antsibull_nox-0.5.0.dist-info → antsibull_nox-0.7.0.dist-info}/METADATA +9 -7
- antsibull_nox-0.7.0.dist-info/RECORD +47 -0
- antsibull_nox-0.5.0.dist-info/RECORD +0 -41
- {antsibull_nox-0.5.0.dist-info → antsibull_nox-0.7.0.dist-info}/WHEEL +0 -0
- {antsibull_nox-0.5.0.dist-info → antsibull_nox-0.7.0.dist-info}/entry_points.txt +0 -0
- {antsibull_nox-0.5.0.dist-info → antsibull_nox-0.7.0.dist-info}/licenses/LICENSES/GPL-3.0-or-later.txt +0 -0
antsibull_nox/sessions/lint.py
CHANGED
@@ -25,6 +25,7 @@ from .collections import (
|
|
25
25
|
CollectionSetup,
|
26
26
|
prepare_collections,
|
27
27
|
)
|
28
|
+
from .docs_check import find_extra_docs_rst_files
|
28
29
|
from .utils import (
|
29
30
|
IN_CI,
|
30
31
|
compose_description,
|
@@ -94,6 +95,128 @@ def add_lint(
|
|
94
95
|
)(lint)
|
95
96
|
|
96
97
|
|
98
|
+
def _execute_isort(
|
99
|
+
session: nox.Session,
|
100
|
+
*,
|
101
|
+
run_check: bool,
|
102
|
+
extra_code_files: list[str],
|
103
|
+
isort_config: str | os.PathLike | None,
|
104
|
+
) -> None:
|
105
|
+
command: list[str] = [
|
106
|
+
"isort",
|
107
|
+
]
|
108
|
+
if run_check:
|
109
|
+
command.append("--check")
|
110
|
+
if isort_config is not None:
|
111
|
+
command.extend(["--settings-file", str(isort_config)])
|
112
|
+
command.extend(session.posargs)
|
113
|
+
command.extend(filter_paths(CODE_FILES + ["noxfile.py"] + extra_code_files))
|
114
|
+
session.run(*command)
|
115
|
+
|
116
|
+
|
117
|
+
def _execute_black_for(
|
118
|
+
session: nox.Session,
|
119
|
+
*,
|
120
|
+
paths: list[str],
|
121
|
+
run_check: bool,
|
122
|
+
black_config: str | os.PathLike | None,
|
123
|
+
) -> None:
|
124
|
+
if not paths:
|
125
|
+
return
|
126
|
+
command = ["black"]
|
127
|
+
if run_check:
|
128
|
+
command.append("--check")
|
129
|
+
if black_config is not None:
|
130
|
+
command.extend(["--config", str(black_config)])
|
131
|
+
command.extend(session.posargs)
|
132
|
+
command.extend(paths)
|
133
|
+
session.run(*command)
|
134
|
+
|
135
|
+
|
136
|
+
def _execute_black(
|
137
|
+
session: nox.Session,
|
138
|
+
*,
|
139
|
+
run_check: bool,
|
140
|
+
extra_code_files: list[str],
|
141
|
+
run_black: bool,
|
142
|
+
run_black_modules: bool | None,
|
143
|
+
black_config: str | os.PathLike | None,
|
144
|
+
) -> None:
|
145
|
+
if run_black and run_black_modules:
|
146
|
+
_execute_black_for(
|
147
|
+
session,
|
148
|
+
paths=filter_paths(CODE_FILES + ["noxfile.py"] + extra_code_files),
|
149
|
+
run_check=run_check,
|
150
|
+
black_config=black_config,
|
151
|
+
)
|
152
|
+
return
|
153
|
+
if run_black:
|
154
|
+
paths = (
|
155
|
+
filter_paths(
|
156
|
+
CODE_FILES,
|
157
|
+
remove=MODULE_PATHS,
|
158
|
+
extensions=[".py"],
|
159
|
+
)
|
160
|
+
+ ["noxfile.py"]
|
161
|
+
+ extra_code_files
|
162
|
+
)
|
163
|
+
_execute_black_for(
|
164
|
+
session, paths=paths, run_check=run_check, black_config=black_config
|
165
|
+
)
|
166
|
+
if run_black_modules:
|
167
|
+
paths = filter_paths(
|
168
|
+
CODE_FILES,
|
169
|
+
restrict=MODULE_PATHS,
|
170
|
+
extensions=[".py"],
|
171
|
+
)
|
172
|
+
_execute_black_for(
|
173
|
+
session, paths=paths, run_check=run_check, black_config=black_config
|
174
|
+
)
|
175
|
+
|
176
|
+
|
177
|
+
def _execute_ruff_format(
|
178
|
+
session: nox.Session,
|
179
|
+
*,
|
180
|
+
run_check: bool,
|
181
|
+
extra_code_files: list[str],
|
182
|
+
ruff_format_config: str | os.PathLike | None,
|
183
|
+
) -> None:
|
184
|
+
command: list[str] = [
|
185
|
+
"ruff",
|
186
|
+
"format",
|
187
|
+
]
|
188
|
+
if run_check:
|
189
|
+
command.append("--check")
|
190
|
+
if ruff_format_config is not None:
|
191
|
+
command.extend(["--config", str(ruff_format_config)])
|
192
|
+
command.extend(session.posargs)
|
193
|
+
command.extend(filter_paths(CODE_FILES + ["noxfile.py"] + extra_code_files))
|
194
|
+
session.run(*command)
|
195
|
+
|
196
|
+
|
197
|
+
def _execute_ruff_autofix(
|
198
|
+
session: nox.Session,
|
199
|
+
*,
|
200
|
+
run_check: bool,
|
201
|
+
extra_code_files: list[str],
|
202
|
+
ruff_autofix_config: str | os.PathLike | None,
|
203
|
+
ruff_autofix_select: list[str],
|
204
|
+
) -> None:
|
205
|
+
command: list[str] = [
|
206
|
+
"ruff",
|
207
|
+
"check",
|
208
|
+
]
|
209
|
+
if not run_check:
|
210
|
+
command.append("--fix")
|
211
|
+
if ruff_autofix_config is not None:
|
212
|
+
command.extend(["--config", str(ruff_autofix_config)])
|
213
|
+
if ruff_autofix_select:
|
214
|
+
command.extend(["--select", ",".join(ruff_autofix_select)])
|
215
|
+
command.extend(session.posargs)
|
216
|
+
command.extend(filter_paths(CODE_FILES + ["noxfile.py"] + extra_code_files))
|
217
|
+
session.run(*command)
|
218
|
+
|
219
|
+
|
97
220
|
def add_formatters(
|
98
221
|
*,
|
99
222
|
extra_code_files: list[str],
|
@@ -106,6 +229,15 @@ def add_formatters(
|
|
106
229
|
run_black_modules: bool | None,
|
107
230
|
black_config: str | os.PathLike | None,
|
108
231
|
black_package: str,
|
232
|
+
# ruff format:
|
233
|
+
run_ruff_format: bool,
|
234
|
+
ruff_format_config: str | os.PathLike | None,
|
235
|
+
ruff_format_package: str,
|
236
|
+
# ruff autofix:
|
237
|
+
run_ruff_autofix: bool,
|
238
|
+
ruff_autofix_config: str | os.PathLike | None,
|
239
|
+
ruff_autofix_package: str,
|
240
|
+
ruff_autofix_select: list[str],
|
109
241
|
) -> None:
|
110
242
|
"""
|
111
243
|
Add nox session for formatters.
|
@@ -120,63 +252,52 @@ def add_formatters(
|
|
120
252
|
deps.append(isort_package)
|
121
253
|
if run_black or run_black_modules:
|
122
254
|
deps.append(black_package)
|
255
|
+
if (
|
256
|
+
run_ruff_format
|
257
|
+
and run_ruff_autofix
|
258
|
+
and ruff_format_package == ruff_autofix_package
|
259
|
+
):
|
260
|
+
deps.append(ruff_format_package)
|
261
|
+
else:
|
262
|
+
if run_ruff_format:
|
263
|
+
deps.append(ruff_format_package)
|
264
|
+
if run_ruff_autofix:
|
265
|
+
deps.append(ruff_autofix_package)
|
123
266
|
return deps
|
124
267
|
|
125
|
-
def execute_isort(session: nox.Session) -> None:
|
126
|
-
command: list[str] = [
|
127
|
-
"isort",
|
128
|
-
]
|
129
|
-
if run_check:
|
130
|
-
command.append("--check")
|
131
|
-
if isort_config is not None:
|
132
|
-
command.extend(["--settings-file", str(isort_config)])
|
133
|
-
command.extend(session.posargs)
|
134
|
-
command.extend(filter_paths(CODE_FILES + ["noxfile.py"] + extra_code_files))
|
135
|
-
session.run(*command)
|
136
|
-
|
137
|
-
def execute_black_for(session: nox.Session, paths: list[str]) -> None:
|
138
|
-
if not paths:
|
139
|
-
return
|
140
|
-
command = ["black"]
|
141
|
-
if run_check:
|
142
|
-
command.append("--check")
|
143
|
-
if black_config is not None:
|
144
|
-
command.extend(["--config", str(black_config)])
|
145
|
-
command.extend(session.posargs)
|
146
|
-
command.extend(paths)
|
147
|
-
session.run(*command)
|
148
|
-
|
149
|
-
def execute_black(session: nox.Session) -> None:
|
150
|
-
if run_black and run_black_modules:
|
151
|
-
execute_black_for(
|
152
|
-
session, filter_paths(CODE_FILES + ["noxfile.py"] + extra_code_files)
|
153
|
-
)
|
154
|
-
return
|
155
|
-
if run_black:
|
156
|
-
paths = (
|
157
|
-
filter_paths(
|
158
|
-
CODE_FILES,
|
159
|
-
remove=MODULE_PATHS,
|
160
|
-
extensions=[".py"],
|
161
|
-
)
|
162
|
-
+ ["noxfile.py"]
|
163
|
-
+ extra_code_files
|
164
|
-
)
|
165
|
-
execute_black_for(session, paths)
|
166
|
-
if run_black_modules:
|
167
|
-
paths = filter_paths(
|
168
|
-
CODE_FILES,
|
169
|
-
restrict=MODULE_PATHS,
|
170
|
-
extensions=[".py"],
|
171
|
-
)
|
172
|
-
execute_black_for(session, paths)
|
173
|
-
|
174
268
|
def formatters(session: nox.Session) -> None:
|
175
269
|
install(session, *compose_dependencies())
|
176
270
|
if run_isort:
|
177
|
-
|
271
|
+
_execute_isort(
|
272
|
+
session,
|
273
|
+
run_check=run_check,
|
274
|
+
extra_code_files=extra_code_files,
|
275
|
+
isort_config=isort_config,
|
276
|
+
)
|
178
277
|
if run_black or run_black_modules:
|
179
|
-
|
278
|
+
_execute_black(
|
279
|
+
session,
|
280
|
+
run_check=run_check,
|
281
|
+
extra_code_files=extra_code_files,
|
282
|
+
run_black=run_black,
|
283
|
+
run_black_modules=run_black_modules,
|
284
|
+
black_config=black_config,
|
285
|
+
)
|
286
|
+
if run_ruff_format:
|
287
|
+
_execute_ruff_format(
|
288
|
+
session,
|
289
|
+
run_check=run_check,
|
290
|
+
extra_code_files=extra_code_files,
|
291
|
+
ruff_format_config=ruff_format_config,
|
292
|
+
)
|
293
|
+
if run_ruff_autofix:
|
294
|
+
_execute_ruff_autofix(
|
295
|
+
session,
|
296
|
+
run_check=run_check,
|
297
|
+
extra_code_files=extra_code_files,
|
298
|
+
ruff_autofix_config=ruff_autofix_config,
|
299
|
+
ruff_autofix_select=ruff_autofix_select,
|
300
|
+
)
|
180
301
|
|
181
302
|
formatters.__doc__ = compose_description(
|
182
303
|
prefix={
|
@@ -186,6 +307,8 @@ def add_formatters(
|
|
186
307
|
programs={
|
187
308
|
"isort": run_isort,
|
188
309
|
"black": run_black,
|
310
|
+
"ruff format": run_ruff_format,
|
311
|
+
"ruff check --fix": run_ruff_autofix,
|
189
312
|
},
|
190
313
|
)
|
191
314
|
nox.session(name="formatters", default=False)(formatters)
|
@@ -216,6 +339,10 @@ def process_pylint_errors(
|
|
216
339
|
def add_codeqa( # noqa: C901
|
217
340
|
*,
|
218
341
|
extra_code_files: list[str],
|
342
|
+
# ruff check:
|
343
|
+
run_ruff_check: bool,
|
344
|
+
ruff_check_config: str | os.PathLike | None,
|
345
|
+
ruff_check_package: str,
|
219
346
|
# flake8:
|
220
347
|
run_flake8: bool,
|
221
348
|
flake8_config: str | os.PathLike | None,
|
@@ -234,6 +361,8 @@ def add_codeqa( # noqa: C901
|
|
234
361
|
|
235
362
|
def compose_dependencies() -> list[str]:
|
236
363
|
deps = []
|
364
|
+
if run_ruff_check:
|
365
|
+
deps.append(ruff_check_package)
|
237
366
|
if run_flake8:
|
238
367
|
deps.append(flake8_package)
|
239
368
|
if run_pylint:
|
@@ -248,6 +377,17 @@ def add_codeqa( # noqa: C901
|
|
248
377
|
deps.extend(shlex.split(extra_dep))
|
249
378
|
return deps
|
250
379
|
|
380
|
+
def execute_ruff_check(session: nox.Session) -> None:
|
381
|
+
command: list[str] = [
|
382
|
+
"ruff",
|
383
|
+
"check",
|
384
|
+
]
|
385
|
+
if ruff_check_config is not None:
|
386
|
+
command.extend(["--config", str(ruff_check_config)])
|
387
|
+
command.extend(session.posargs)
|
388
|
+
command.extend(filter_paths(CODE_FILES + ["noxfile.py"] + extra_code_files))
|
389
|
+
session.run(*command)
|
390
|
+
|
251
391
|
def execute_flake8(session: nox.Session) -> None:
|
252
392
|
command: list[str] = [
|
253
393
|
"flake8",
|
@@ -326,6 +466,8 @@ def add_codeqa( # noqa: C901
|
|
326
466
|
)
|
327
467
|
if not prepared_collections:
|
328
468
|
session.warn("Skipping pylint...")
|
469
|
+
if run_ruff_check:
|
470
|
+
execute_ruff_check(session)
|
329
471
|
if run_flake8:
|
330
472
|
execute_flake8(session)
|
331
473
|
if run_pylint and prepared_collections:
|
@@ -336,6 +478,7 @@ def add_codeqa( # noqa: C901
|
|
336
478
|
"other": "Run code QA:",
|
337
479
|
},
|
338
480
|
programs={
|
481
|
+
"ruff check": run_ruff_check,
|
339
482
|
"flake8": run_flake8,
|
340
483
|
"pylint": run_pylint,
|
341
484
|
},
|
@@ -349,7 +492,9 @@ def add_yamllint(
|
|
349
492
|
yamllint_config: str | os.PathLike | None,
|
350
493
|
yamllint_config_plugins: str | os.PathLike | None,
|
351
494
|
yamllint_config_plugins_examples: str | os.PathLike | None,
|
495
|
+
yamllint_config_extra_docs: str | os.PathLike | None,
|
352
496
|
yamllint_package: str,
|
497
|
+
yamllint_antsibull_docutils_package: str,
|
353
498
|
) -> None:
|
354
499
|
"""
|
355
500
|
Add yamllint session for linting YAML files and plugin/module docs.
|
@@ -358,14 +503,13 @@ def add_yamllint(
|
|
358
503
|
def compose_dependencies() -> list[str]:
|
359
504
|
deps = []
|
360
505
|
if run_yamllint:
|
361
|
-
deps.
|
506
|
+
deps.extend([yamllint_package, yamllint_antsibull_docutils_package])
|
362
507
|
return deps
|
363
508
|
|
364
509
|
def to_str(config: str | os.PathLike | None) -> str | None:
|
365
510
|
return str(config) if config else None
|
366
511
|
|
367
512
|
def execute_yamllint(session: nox.Session) -> None:
|
368
|
-
# Run yamllint
|
369
513
|
all_files = list_all_files()
|
370
514
|
all_yaml_filenames = [
|
371
515
|
file for file in all_files if file.name.lower().endswith((".yml", ".yaml"))
|
@@ -385,7 +529,6 @@ def add_yamllint(
|
|
385
529
|
)
|
386
530
|
|
387
531
|
def execute_plugin_yamllint(session: nox.Session) -> None:
|
388
|
-
# Run yamllint
|
389
532
|
all_files = list_all_files()
|
390
533
|
cwd = Path.cwd()
|
391
534
|
plugins_dir = cwd / "plugins"
|
@@ -422,11 +565,35 @@ def add_yamllint(
|
|
422
565
|
},
|
423
566
|
)
|
424
567
|
|
568
|
+
def execute_extra_docs_yamllint(session: nox.Session) -> None:
|
569
|
+
all_extra_docs = find_extra_docs_rst_files()
|
570
|
+
if not all_extra_docs:
|
571
|
+
session.warn(
|
572
|
+
"Skipping yamllint for extra docs since"
|
573
|
+
" no appropriate RST file was found..."
|
574
|
+
)
|
575
|
+
return
|
576
|
+
run_bare_script(
|
577
|
+
session,
|
578
|
+
"rst-yamllint",
|
579
|
+
use_session_python=True,
|
580
|
+
files=all_extra_docs,
|
581
|
+
extra_data={
|
582
|
+
"config": to_str(
|
583
|
+
yamllint_config_extra_docs
|
584
|
+
or yamllint_config_plugins_examples
|
585
|
+
or yamllint_config_plugins
|
586
|
+
or yamllint_config
|
587
|
+
),
|
588
|
+
},
|
589
|
+
)
|
590
|
+
|
425
591
|
def yamllint(session: nox.Session) -> None:
|
426
592
|
install(session, *compose_dependencies())
|
427
593
|
if run_yamllint:
|
428
594
|
execute_yamllint(session)
|
429
595
|
execute_plugin_yamllint(session)
|
596
|
+
execute_extra_docs_yamllint(session)
|
430
597
|
|
431
598
|
yamllint.__doc__ = compose_description(
|
432
599
|
prefix={
|
@@ -594,6 +761,19 @@ def add_lint_sessions(
|
|
594
761
|
run_black_modules: bool | None = None,
|
595
762
|
black_config: str | os.PathLike | None = None,
|
596
763
|
black_package: str = "black",
|
764
|
+
# ruff format:
|
765
|
+
run_ruff_format: bool = False,
|
766
|
+
ruff_format_config: str | os.PathLike | None = None,
|
767
|
+
ruff_format_package: str = "ruff",
|
768
|
+
# ruff autofix:
|
769
|
+
run_ruff_autofix: bool = False,
|
770
|
+
ruff_autofix_config: str | os.PathLike | None = None,
|
771
|
+
ruff_autofix_package: str = "ruff",
|
772
|
+
ruff_autofix_select: list[str] | None = None,
|
773
|
+
# ruff check:
|
774
|
+
run_ruff_check: bool = False,
|
775
|
+
ruff_check_config: str | os.PathLike | None = None,
|
776
|
+
ruff_check_package: str = "ruff",
|
597
777
|
# flake8:
|
598
778
|
run_flake8: bool = True,
|
599
779
|
flake8_config: str | os.PathLike | None = None,
|
@@ -610,7 +790,9 @@ def add_lint_sessions(
|
|
610
790
|
yamllint_config: str | os.PathLike | None = None,
|
611
791
|
yamllint_config_plugins: str | os.PathLike | None = None,
|
612
792
|
yamllint_config_plugins_examples: str | os.PathLike | None = None,
|
793
|
+
yamllint_config_extra_docs: str | os.PathLike | None = None,
|
613
794
|
yamllint_package: str = "yamllint",
|
795
|
+
yamllint_antsibull_docutils_package: str = "antsibull-docutils",
|
614
796
|
# mypy:
|
615
797
|
run_mypy: bool = True,
|
616
798
|
mypy_config: str | os.PathLike | None = None,
|
@@ -623,8 +805,15 @@ def add_lint_sessions(
|
|
623
805
|
"""
|
624
806
|
Add nox sessions for linting.
|
625
807
|
"""
|
626
|
-
has_formatters =
|
627
|
-
|
808
|
+
has_formatters = (
|
809
|
+
run_isort
|
810
|
+
or run_black
|
811
|
+
or run_black_modules
|
812
|
+
or False
|
813
|
+
or run_ruff_format
|
814
|
+
or run_ruff_autofix
|
815
|
+
)
|
816
|
+
has_codeqa = run_ruff_check or run_flake8 or run_pylint
|
628
817
|
has_yamllint = run_yamllint
|
629
818
|
has_typing = run_mypy
|
630
819
|
has_config_lint = run_antsibullnox_config_lint
|
@@ -648,11 +837,21 @@ def add_lint_sessions(
|
|
648
837
|
run_black_modules=run_black_modules,
|
649
838
|
black_config=black_config,
|
650
839
|
black_package=black_package,
|
840
|
+
run_ruff_format=run_ruff_format,
|
841
|
+
ruff_format_config=ruff_format_config,
|
842
|
+
ruff_format_package=ruff_format_package,
|
843
|
+
run_ruff_autofix=run_ruff_autofix,
|
844
|
+
ruff_autofix_config=ruff_autofix_config,
|
845
|
+
ruff_autofix_package=ruff_autofix_package,
|
846
|
+
ruff_autofix_select=ruff_autofix_select or [],
|
651
847
|
)
|
652
848
|
|
653
849
|
if has_codeqa:
|
654
850
|
add_codeqa(
|
655
851
|
extra_code_files=extra_code_files or [],
|
852
|
+
run_ruff_check=run_ruff_check,
|
853
|
+
ruff_check_config=ruff_check_config,
|
854
|
+
ruff_check_package=ruff_check_package,
|
656
855
|
run_flake8=run_flake8,
|
657
856
|
flake8_config=flake8_config,
|
658
857
|
flake8_package=flake8_package,
|
@@ -670,7 +869,9 @@ def add_lint_sessions(
|
|
670
869
|
yamllint_config=yamllint_config,
|
671
870
|
yamllint_config_plugins=yamllint_config_plugins,
|
672
871
|
yamllint_config_plugins_examples=yamllint_config_plugins_examples,
|
872
|
+
yamllint_config_extra_docs=yamllint_config_extra_docs,
|
673
873
|
yamllint_package=yamllint_package,
|
874
|
+
yamllint_antsibull_docutils_package=yamllint_antsibull_docutils_package,
|
674
875
|
)
|
675
876
|
|
676
877
|
if has_typing:
|
antsibull_nox/sessions/utils.py
CHANGED
@@ -10,6 +10,7 @@ Utils for creating nox sessions.
|
|
10
10
|
|
11
11
|
from __future__ import annotations
|
12
12
|
|
13
|
+
import json
|
13
14
|
import logging
|
14
15
|
import os
|
15
16
|
import sys
|
@@ -19,6 +20,8 @@ from pathlib import Path
|
|
19
20
|
|
20
21
|
import nox
|
21
22
|
from nox.logger import OUTPUT as nox_OUTPUT
|
23
|
+
from packaging.version import InvalidVersion
|
24
|
+
from packaging.version import parse as parse_version
|
22
25
|
|
23
26
|
from ..data_util import prepare_data_script
|
24
27
|
from ..paths import (
|
@@ -151,6 +154,86 @@ def run_bare_script(
|
|
151
154
|
)
|
152
155
|
|
153
156
|
|
157
|
+
def get_package_versions(
|
158
|
+
session: nox.Session,
|
159
|
+
/,
|
160
|
+
packages: list[str] | str,
|
161
|
+
*,
|
162
|
+
use_session_python: bool = True,
|
163
|
+
) -> None | dict[str, str | None]:
|
164
|
+
"""
|
165
|
+
Retrieve the versions of one or more Python packages.
|
166
|
+
"""
|
167
|
+
name = "get-package-versions"
|
168
|
+
if isinstance(packages, str):
|
169
|
+
packages = [packages]
|
170
|
+
if not packages:
|
171
|
+
return {}
|
172
|
+
data = prepare_data_script(
|
173
|
+
session,
|
174
|
+
base_name=name,
|
175
|
+
paths=[],
|
176
|
+
extra_data={
|
177
|
+
"packages": packages,
|
178
|
+
},
|
179
|
+
)
|
180
|
+
python = sys.executable
|
181
|
+
env = {}
|
182
|
+
if use_session_python:
|
183
|
+
python = "python"
|
184
|
+
env["PYTHONPATH"] = str(find_data_directory())
|
185
|
+
result = session.run(
|
186
|
+
python,
|
187
|
+
find_data_directory() / f"{name}.py",
|
188
|
+
"--data",
|
189
|
+
data,
|
190
|
+
external=True,
|
191
|
+
silent=True,
|
192
|
+
env=env,
|
193
|
+
)
|
194
|
+
if result is None:
|
195
|
+
return None
|
196
|
+
return json.loads(result)
|
197
|
+
|
198
|
+
|
199
|
+
def get_package_version(
|
200
|
+
session: nox.Session,
|
201
|
+
/,
|
202
|
+
package: str,
|
203
|
+
*,
|
204
|
+
use_session_python: bool = True,
|
205
|
+
) -> str | None:
|
206
|
+
"""
|
207
|
+
Retrieve a Python package's version.
|
208
|
+
"""
|
209
|
+
result = get_package_versions(
|
210
|
+
session, package, use_session_python=use_session_python
|
211
|
+
)
|
212
|
+
return None if result is None else result.get(package)
|
213
|
+
|
214
|
+
|
215
|
+
def is_new_enough(actual_version: str | None, *, min_version: str) -> bool:
|
216
|
+
"""
|
217
|
+
Given a program version, compares it to the min_version.
|
218
|
+
If the program version is not given, it is assumed to be "new enough".
|
219
|
+
"""
|
220
|
+
if actual_version is None:
|
221
|
+
return True
|
222
|
+
try:
|
223
|
+
act_v = parse_version(actual_version)
|
224
|
+
except InvalidVersion as exc:
|
225
|
+
raise ValueError(
|
226
|
+
f"Cannot parse actual version {actual_version!r}: {exc}"
|
227
|
+
) from exc
|
228
|
+
try:
|
229
|
+
min_v = parse_version(min_version)
|
230
|
+
except InvalidVersion as exc:
|
231
|
+
raise ValueError(
|
232
|
+
f"Cannot parse minimum version {min_version!r}: {exc}"
|
233
|
+
) from exc
|
234
|
+
return act_v >= min_v
|
235
|
+
|
236
|
+
|
154
237
|
def compose_description(
|
155
238
|
*,
|
156
239
|
prefix: str | dict[t.Literal["one", "other"], str] | None = None,
|
@@ -197,8 +280,11 @@ def compose_description(
|
|
197
280
|
__all__ = [
|
198
281
|
"ci_group",
|
199
282
|
"compose_description",
|
283
|
+
"get_package_version",
|
284
|
+
"get_package_versions",
|
200
285
|
"get_registered_sessions",
|
201
286
|
"install",
|
287
|
+
"is_new_enough",
|
202
288
|
"nox_has_verbosity",
|
203
289
|
"register",
|
204
290
|
"run_bare_script",
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: antsibull-nox
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.7.0
|
4
4
|
Summary: Changelog tool for Ansible-core and Ansible collections
|
5
5
|
Project-URL: Documentation, https://ansible.readthedocs.io/projects/antsibull-nox/
|
6
6
|
Project-URL: Source code, https://github.com/ansible-community/antsibull-nox/
|
@@ -22,7 +22,7 @@ Classifier: Programming Language :: Python :: 3.12
|
|
22
22
|
Classifier: Programming Language :: Python :: 3.13
|
23
23
|
Classifier: Typing :: Typed
|
24
24
|
Requires-Python: >=3.9.0
|
25
|
-
Requires-Dist: antsibull-fileutils<2.0.0,>=1.
|
25
|
+
Requires-Dist: antsibull-fileutils<2.0.0,>=1.3.0
|
26
26
|
Requires-Dist: nox>=2025.2.9
|
27
27
|
Requires-Dist: packaging
|
28
28
|
Requires-Dist: pydantic~=2.0
|
@@ -38,6 +38,7 @@ Provides-Extra: coverage
|
|
38
38
|
Requires-Dist: coverage[toml]; extra == 'coverage'
|
39
39
|
Provides-Extra: dev
|
40
40
|
Requires-Dist: antsibull-changelog; extra == 'dev'
|
41
|
+
Requires-Dist: antsibull-docutils>=1.2.0; extra == 'dev'
|
41
42
|
Requires-Dist: black>=24; extra == 'dev'
|
42
43
|
Requires-Dist: coverage[toml]; extra == 'dev'
|
43
44
|
Requires-Dist: flake8>=3.8.0; extra == 'dev'
|
@@ -58,6 +59,7 @@ Requires-Dist: pytest; extra == 'test'
|
|
58
59
|
Requires-Dist: pytest-cov; extra == 'test'
|
59
60
|
Requires-Dist: pytest-error-for-skips; extra == 'test'
|
60
61
|
Provides-Extra: typing
|
62
|
+
Requires-Dist: antsibull-docutils>=1.2.0; extra == 'typing'
|
61
63
|
Requires-Dist: mypy; extra == 'typing'
|
62
64
|
Requires-Dist: types-pyyaml; extra == 'typing'
|
63
65
|
Description-Content-Type: text/markdown
|
@@ -104,15 +106,15 @@ and install the requirements needed to run the tests there.
|
|
104
106
|
|
105
107
|
---
|
106
108
|
|
107
|
-
antsibull-nox depends on the sister antsibull-fileutils
|
108
|
-
By default, `nox` will install
|
109
|
-
If you're hacking on antsibull-fileutils alongside antsibull-nox,
|
110
|
-
nox will automatically install
|
109
|
+
antsibull-nox depends on the sister antsibull-docutils and antsibull-fileutils projects.
|
110
|
+
By default, `nox` will install development versions of this projects from Github.
|
111
|
+
If you're hacking on antsibull-docutils and/or antsibull-fileutils alongside antsibull-nox,
|
112
|
+
nox will automatically install these projects from `../antsibull-docutils` and `../antsibull-fileutils`
|
111
113
|
when running tests if those paths exist.
|
112
114
|
You can change this behavior through the `OTHER_ANTSIBULL_MODE` env var:
|
113
115
|
|
114
116
|
- `OTHER_ANTSIBULL_MODE=auto` — the default behavior described above
|
115
|
-
- `OTHER_ANTSIBULL_MODE=local` — install the
|
117
|
+
- `OTHER_ANTSIBULL_MODE=local` — install the projects from `../antsibull-docutils` and `../antsibull-fileutils`.
|
116
118
|
Fail if that path doesn't exist.
|
117
119
|
- `OTHER_ANTSIBULL_MODE=git` — install the projects from the Github main branch
|
118
120
|
- `OTHER_ANTSIBULL_MODE=pypi` — install the latest versions from PyPI
|
@@ -0,0 +1,47 @@
|
|
1
|
+
antsibull_nox/__init__.py,sha256=ckHydw6Ts2rrrm2iLtHD3zxDxG1JkL6YGHBL8_HrFbY,845
|
2
|
+
antsibull_nox/_pydantic.py,sha256=VTIh-u0TpWvnY6Dhe4ba8nAmR2tYmz4PXNp2_8Sr9pw,3203
|
3
|
+
antsibull_nox/ansible.py,sha256=bPMwpkhk16ALoOfylFUK_sMKMhAXP5h7qyviDlC9A1Y,9338
|
4
|
+
antsibull_nox/cli.py,sha256=NKeRlWc_0taNRcZcdMv9LHZ5nCz8-DEJxBLPxJ9vFYQ,3358
|
5
|
+
antsibull_nox/config.py,sha256=_wPvRQ_RZq0qBXEU0o6Kxf-SbU3nRZZSo-5bYHdeUts,12240
|
6
|
+
antsibull_nox/data_util.py,sha256=7FVoqESEc-_QdqrQ16K1AHRVHEglNbRCH_mNaYDJ7a4,953
|
7
|
+
antsibull_nox/init.py,sha256=eRltIrS3AcHqEHk2yNAqJXv7kR6m_ysvFxIHpowd-2M,2259
|
8
|
+
antsibull_nox/interpret_config.py,sha256=Cf2sHcbrucVHSxuOGIT_XcIhRBDoYM0RmKg97ZFBp1k,12854
|
9
|
+
antsibull_nox/lint_config.py,sha256=ZnsUbX6IdQK_IP9nvs8Kk6jb5lPdiREFSHAUuEGGceU,3848
|
10
|
+
antsibull_nox/paths.py,sha256=3XmzChWADLvp0u0NenliPNjX2gV1LBDuUv5-Q6rsftY,6325
|
11
|
+
antsibull_nox/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
12
|
+
antsibull_nox/python.py,sha256=0pyGqgwsuyc0BhzoXNZLTLbjaFA4kAYEHrFD6A1o1-o,2113
|
13
|
+
antsibull_nox/utils.py,sha256=lgBNuJ67Agl9YpFNWCjr6TBUcbC1LroZrJkv6S5VuxA,2437
|
14
|
+
antsibull_nox/collection/__init__.py,sha256=TvH_zzVr5f6VapLMcinuSF8qj6VXP2afhRd116mWiH8,944
|
15
|
+
antsibull_nox/collection/build.py,sha256=9gjNC7u6ueykMPawC3OgZZmfvPwfNCIPkRoaK-R_Ulw,1827
|
16
|
+
antsibull_nox/collection/data.py,sha256=HmnASNuv97xFM08gYuQcAF3Nz6Oc6eXd5NN-wbMtYUU,2966
|
17
|
+
antsibull_nox/collection/extract.py,sha256=qNVknQRtRrCt10aawuU1Z6NTs16CA1bUEX3WDGBw68g,684
|
18
|
+
antsibull_nox/collection/install.py,sha256=xRXJ0kY8J1eOMmtHBZC6DqG38BF-RhjhvLF-GRT-Bb0,21622
|
19
|
+
antsibull_nox/collection/search.py,sha256=WZkcgNldl-feAqtKvn9fMMFxJ46kLeS0mqU-5R6yt7o,19296
|
20
|
+
antsibull_nox/collection/utils.py,sha256=1iqlaNsdtB8PEkGV_5zyc3PU9X9pUpHJgGrgoz4s7mA,1077
|
21
|
+
antsibull_nox/data/action-groups.py,sha256=SoKoBXYoI_zCoFJ6p39_46M9lWzhwFeCQ8kib2gQpI4,7332
|
22
|
+
antsibull_nox/data/antsibull-nox-lint-config.py,sha256=tXkKd9AqgfDs5w7S6OaBIt9HnT0KSbiQIU9tFxtYE2U,657
|
23
|
+
antsibull_nox/data/antsibull_nox_data_util.py,sha256=KBviE-NslEjmow1C5eORxj579RXobihEixClj-lrCgE,3350
|
24
|
+
antsibull_nox/data/file-yamllint.py,sha256=hlS9tULwQSUMkdbYFfGtQGcPSj2scxEay6IalQfjSFE,3625
|
25
|
+
antsibull_nox/data/get-package-versions.py,sha256=GRp6cNf-aN_05d8-WOBtp6EcRja4-VFBjcB92xS_pFA,940
|
26
|
+
antsibull_nox/data/license-check.py,sha256=or3GyQC0WWYMxMqL-369krGsHaySH1vX-2fwpRyJGp0,5665
|
27
|
+
antsibull_nox/data/license-check.py.license,sha256=iPdFtdkeE3E2nCB-M5KHevbz4d5I-6ymOnKNTc954Dw,218
|
28
|
+
antsibull_nox/data/no-trailing-whitespace.py,sha256=vPbrTWR-GRIb0SVTY-jV5nTkMJQP8Ta0wD73eBu5N40,1596
|
29
|
+
antsibull_nox/data/no-unwanted-files.py,sha256=ODXu1O16RsdBi8jjg-sKz_2CHhK31yHD9-58qNf_clA,2962
|
30
|
+
antsibull_nox/data/plugin-yamllint.py,sha256=bPIFmNwuTznaUjUhebccFa0IF_joyjIO7d3uF2HqjZQ,8466
|
31
|
+
antsibull_nox/data/rst-extra.py,sha256=zR6qDtpAx6hLAqCT3AJ4Fx1aViCw_wQkGkMqIn69s-s,5527
|
32
|
+
antsibull_nox/data/rst-yamllint.py,sha256=QZntH4h6HnoV4glFejg2YMwnP3GUGN1tgUhYwTQ_D7c,5688
|
33
|
+
antsibull_nox/sessions/__init__.py,sha256=4wTTO1E6rdCz4pVMuGUeuXi_vqFaH4whAL9qcjfOqto,2022
|
34
|
+
antsibull_nox/sessions/ansible_lint.py,sha256=ik2heGsvpRwYm_4XGwlm53UvWQ_7FHDWaBt7ttvUYbU,1661
|
35
|
+
antsibull_nox/sessions/ansible_test.py,sha256=apHRgq8n2VDCEAce9wN6di9vM9ZNQKvXH4bhifefLvI,21006
|
36
|
+
antsibull_nox/sessions/build_import_check.py,sha256=QgM5531eqo3AD7LPOJUKW3I23peEpb6oFLa6uu9DUv4,3683
|
37
|
+
antsibull_nox/sessions/collections.py,sha256=nhj_W2tbnsVJw6p7NkyP1xvmr3ZUmSJzwVuK0HE3oxw,4681
|
38
|
+
antsibull_nox/sessions/docs_check.py,sha256=L9nn6_yshSNFAYSTxjWYegMQzegudaJ-3-tvD69GGW4,4595
|
39
|
+
antsibull_nox/sessions/extra_checks.py,sha256=hKa6x1WaUSaVXvAN1ojM_tXkSTmHfd5A-2eBasyVkss,4910
|
40
|
+
antsibull_nox/sessions/license_check.py,sha256=t5ut4ZluhFfk-qE6kcU8VNdvIGvzND81N7WCsbA4jLc,1824
|
41
|
+
antsibull_nox/sessions/lint.py,sha256=GWXKmrfXIjWRDi3ztDVvbbGLom70-mZncYZm6zjeq-E,28072
|
42
|
+
antsibull_nox/sessions/utils.py,sha256=FlZZJvATdca_cFZeMqoEv1Bfdv971VAta1KyA4W3pi0,7840
|
43
|
+
antsibull_nox-0.7.0.dist-info/METADATA,sha256=kZd3w0-kMvbuZMpFUL3FHZo9iZ43mLEmm_-q4MubqJ0,7896
|
44
|
+
antsibull_nox-0.7.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
45
|
+
antsibull_nox-0.7.0.dist-info/entry_points.txt,sha256=solWA9TCB37UlaGk8sHXxJg-k1HWckfKdncHDBsVSsI,57
|
46
|
+
antsibull_nox-0.7.0.dist-info/licenses/LICENSES/GPL-3.0-or-later.txt,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
47
|
+
antsibull_nox-0.7.0.dist-info/RECORD,,
|