duty 1.6.0__py3-none-any.whl → 1.6.2__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.
Files changed (82) hide show
  1. duty/__init__.py +49 -2
  2. duty/__main__.py +1 -1
  3. duty/_internal/__init__.py +0 -0
  4. duty/_internal/callables/__init__.py +34 -0
  5. duty/{callables → _internal/callables}/_io.py +2 -0
  6. duty/_internal/callables/autoflake.py +132 -0
  7. duty/_internal/callables/black.py +176 -0
  8. duty/_internal/callables/blacken_docs.py +92 -0
  9. duty/_internal/callables/build.py +76 -0
  10. duty/_internal/callables/coverage.py +716 -0
  11. duty/_internal/callables/flake8.py +222 -0
  12. duty/_internal/callables/git_changelog.py +178 -0
  13. duty/_internal/callables/griffe.py +227 -0
  14. duty/_internal/callables/interrogate.py +152 -0
  15. duty/_internal/callables/isort.py +573 -0
  16. duty/_internal/callables/mkdocs.py +256 -0
  17. duty/_internal/callables/mypy.py +496 -0
  18. duty/_internal/callables/pytest.py +475 -0
  19. duty/_internal/callables/ruff.py +399 -0
  20. duty/_internal/callables/safety.py +82 -0
  21. duty/_internal/callables/ssort.py +38 -0
  22. duty/_internal/callables/twine.py +284 -0
  23. duty/_internal/cli.py +322 -0
  24. duty/_internal/collection.py +246 -0
  25. duty/_internal/context.py +111 -0
  26. duty/{debug.py → _internal/debug.py} +13 -15
  27. duty/_internal/decorator.py +111 -0
  28. duty/_internal/exceptions.py +12 -0
  29. duty/_internal/tools/__init__.py +41 -0
  30. duty/{tools → _internal/tools}/_autoflake.py +8 -4
  31. duty/{tools → _internal/tools}/_base.py +15 -2
  32. duty/{tools → _internal/tools}/_black.py +5 -5
  33. duty/{tools → _internal/tools}/_blacken_docs.py +10 -5
  34. duty/{tools → _internal/tools}/_build.py +4 -4
  35. duty/{tools → _internal/tools}/_coverage.py +8 -4
  36. duty/{tools → _internal/tools}/_flake8.py +10 -12
  37. duty/{tools → _internal/tools}/_git_changelog.py +8 -4
  38. duty/{tools → _internal/tools}/_griffe.py +8 -4
  39. duty/{tools → _internal/tools}/_interrogate.py +4 -4
  40. duty/{tools → _internal/tools}/_isort.py +8 -6
  41. duty/{tools → _internal/tools}/_mkdocs.py +8 -4
  42. duty/{tools → _internal/tools}/_mypy.py +5 -5
  43. duty/{tools → _internal/tools}/_pytest.py +8 -4
  44. duty/{tools → _internal/tools}/_ruff.py +11 -5
  45. duty/{tools → _internal/tools}/_safety.py +13 -8
  46. duty/{tools → _internal/tools}/_ssort.py +10 -6
  47. duty/{tools → _internal/tools}/_twine.py +11 -5
  48. duty/_internal/tools/_yore.py +96 -0
  49. duty/_internal/validation.py +266 -0
  50. duty/callables/__init__.py +4 -4
  51. duty/callables/autoflake.py +11 -126
  52. duty/callables/black.py +12 -171
  53. duty/callables/blacken_docs.py +11 -86
  54. duty/callables/build.py +12 -71
  55. duty/callables/coverage.py +12 -711
  56. duty/callables/flake8.py +12 -217
  57. duty/callables/git_changelog.py +12 -173
  58. duty/callables/griffe.py +12 -222
  59. duty/callables/interrogate.py +12 -147
  60. duty/callables/isort.py +12 -568
  61. duty/callables/mkdocs.py +12 -251
  62. duty/callables/mypy.py +11 -490
  63. duty/callables/pytest.py +12 -470
  64. duty/callables/ruff.py +12 -394
  65. duty/callables/safety.py +11 -76
  66. duty/callables/ssort.py +12 -33
  67. duty/callables/twine.py +12 -279
  68. duty/cli.py +10 -316
  69. duty/collection.py +12 -228
  70. duty/context.py +12 -107
  71. duty/decorator.py +12 -108
  72. duty/exceptions.py +13 -10
  73. duty/tools.py +63 -0
  74. duty/validation.py +12 -262
  75. {duty-1.6.0.dist-info → duty-1.6.2.dist-info}/METADATA +5 -4
  76. duty-1.6.2.dist-info/RECORD +81 -0
  77. {duty-1.6.0.dist-info → duty-1.6.2.dist-info}/WHEEL +1 -1
  78. {duty-1.6.0.dist-info → duty-1.6.2.dist-info}/entry_points.txt +1 -1
  79. duty/tools/__init__.py +0 -50
  80. duty/tools/_yore.py +0 -54
  81. duty-1.6.0.dist-info/RECORD +0 -55
  82. {duty-1.6.0.dist-info → duty-1.6.2.dist-info}/licenses/LICENSE +0 -0
@@ -1,716 +1,17 @@
1
- """Callable for [Coverage.py](https://github.com/nedbat/coveragepy)."""
1
+ """Deprecated. Use [`duty.tools.coverage`][] instead."""
2
2
 
3
- from __future__ import annotations
3
+ # YORE: Bump 2: Remove file.
4
4
 
5
- from typing import Literal
5
+ import warnings
6
+ from typing import Any
6
7
 
7
- from failprint.lazy import lazy
8
+ from duty._internal.callables import coverage as _coverage
8
9
 
9
10
 
10
- def _run(args: list[str]) -> None:
11
- from coverage.cmdline import main as coverage
12
-
13
- coverage(args)
14
-
15
-
16
- @lazy(name="coverage.annotate")
17
- def annotate(
18
- *,
19
- rcfile: str | None = None,
20
- directory: str | None = None,
21
- data_file: str | None = None,
22
- ignore_errors: bool | None = None,
23
- include: list[str] | None = None,
24
- omit: list[str] | None = None,
25
- debug_opts: list[str] | None = None,
26
- ) -> None:
27
- """Annotate source files with execution information.
28
-
29
- Make annotated copies of the given files, marking statements that are executed
30
- with `>` and statements that are missed with `!`.
31
-
32
- Parameters:
33
- rcfile: Specify configuration file. By default `.coveragerc`, `setup.cfg`, `tox.ini`,
34
- and `pyproject.toml` are tried [env: `COVERAGE_RCFILE`].
35
- directory: Write the output files to this directory.
36
- data_file: Read coverage data for report generation from this file.
37
- Defaults to `.coverage` [env: `COVERAGE_FILE`].
38
- ignore_errors: Ignore errors while reading source files.
39
- include: Include only files whose paths match one of these patterns. Accepts shell-style wildcards, which must be quoted.
40
- omit: Omit files whose paths match one of these patterns. Accepts shell-style wildcards, which must be quoted.
41
- debug_opts: Debug options, separated by commas [env: `COVERAGE_DEBUG`].
42
- """
43
- cli_args = ["annotate"]
44
-
45
- if directory:
46
- cli_args.append("--directory")
47
- cli_args.append(directory)
48
-
49
- if data_file:
50
- cli_args.append("--data-file")
51
- cli_args.append(data_file)
52
-
53
- if ignore_errors:
54
- cli_args.append("--ignore-errors")
55
-
56
- if include:
57
- cli_args.append("--include")
58
- cli_args.append(",".join(include))
59
-
60
- if omit:
61
- cli_args.append("--omit")
62
- cli_args.append(",".join(omit))
63
-
64
- if debug_opts:
65
- cli_args.append("--debug")
66
- cli_args.append(",".join(debug_opts))
67
-
68
- if rcfile:
69
- cli_args.append("--rcfile")
70
- cli_args.append(rcfile)
71
-
72
- _run(cli_args)
73
-
74
-
75
- @lazy(name="coverage.combine")
76
- def combine(
77
- *paths: str,
78
- rcfile: str | None = None,
79
- append: bool | None = None,
80
- data_file: str | None = None,
81
- keep: bool | None = None,
82
- quiet: bool | None = None,
83
- debug_opts: list[str] | None = None,
84
- ) -> None:
85
- """Combine a number of data files.
86
-
87
- Combine data from multiple coverage files. The combined results are written to
88
- a single file representing the union of the data. The positional arguments are
89
- data files or directories containing data files. If no paths are provided,
90
- data files in the default data file's directory are combined.
91
-
92
- Parameters:
93
- paths: Paths to combine.
94
- rcfile: Specify configuration file. By default `.coveragerc`, `setup.cfg`, `tox.ini`,
95
- and `pyproject.toml` are tried [env: `COVERAGE_RCFILE`].
96
- append: Append coverage data to .coverage, otherwise it starts clean each time.
97
- data_file: Read coverage data for report generation from this file.
98
- Defaults to `.coverage` [env: `COVERAGE_FILE`].
99
- keep: Keep original coverage files, otherwise they are deleted.
100
- quiet: Don't print messages about what is happening.
101
- debug_opts: Debug options, separated by commas [env: `COVERAGE_DEBUG`].
102
- """
103
- cli_args = ["combine", *paths]
104
-
105
- if append:
106
- cli_args.append("--append")
107
-
108
- if data_file:
109
- cli_args.append("--data-file")
110
- cli_args.append(data_file)
111
-
112
- if keep:
113
- cli_args.append("--keep")
114
-
115
- if quiet:
116
- cli_args.append("--quiet")
117
-
118
- if debug_opts:
119
- cli_args.append("--debug")
120
- cli_args.append(",".join(debug_opts))
121
-
122
- if rcfile:
123
- cli_args.append("--rcfile")
124
- cli_args.append(rcfile)
125
-
126
- _run(cli_args)
127
-
128
-
129
- @lazy(name="coverage.debug")
130
- def debug(
131
- topic: Literal["data", "sys", "config", "premain", "pybehave"],
132
- *,
133
- rcfile: str | None = None,
134
- debug_opts: list[str] | None = None,
135
- ) -> None:
136
- """Display information about the internals of coverage.py.
137
-
138
- Display information about the internals of coverage.py, for diagnosing
139
- problems. Topics are: `data` to show a summary of the collected data; `sys` to
140
- show installation information; `config` to show the configuration; `premain`
141
- to show what is calling coverage; `pybehave` to show internal flags describing
142
- Python behavior.
143
-
144
- Parameters:
145
- topic: Topic to display.
146
- rcfile: Specify configuration file. By default `.coveragerc`, `setup.cfg`, `tox.ini`,
147
- and `pyproject.toml` are tried [env: `COVERAGE_RCFILE`].
148
- debug_opts: Debug options, separated by commas [env: `COVERAGE_DEBUG`].
149
- """
150
- cli_args: list[str] = ["debug", topic]
151
-
152
- if debug_opts:
153
- cli_args.append("--debug")
154
- cli_args.append(",".join(debug_opts))
155
-
156
- if rcfile:
157
- cli_args.append("--rcfile")
158
- cli_args.append(rcfile)
159
-
160
- _run(cli_args)
161
-
162
-
163
- @lazy(name="coverage.erase")
164
- def erase(
165
- *,
166
- rcfile: str | None = None,
167
- data_file: str | None = None,
168
- debug_opts: list[str] | None = None,
169
- ) -> None:
170
- """Erase previously collected coverage data.
171
-
172
- Parameters:
173
- rcfile: Specify configuration file. By default `.coveragerc`, `setup.cfg`, `tox.ini`,
174
- and `pyproject.toml` are tried [env: `COVERAGE_RCFILE`].
175
- data_file: Read coverage data for report generation from this file.
176
- Defaults to `.coverage` [env: `COVERAGE_FILE`].
177
- debug_opts: Debug options, separated by commas [env: `COVERAGE_DEBUG`].
178
- """
179
- cli_args = ["erase"]
180
-
181
- if data_file:
182
- cli_args.append("--data-file")
183
- cli_args.append(data_file)
184
-
185
- if debug_opts:
186
- cli_args.append("--debug")
187
- cli_args.append(",".join(debug_opts))
188
-
189
- if rcfile:
190
- cli_args.append("--rcfile")
191
- cli_args.append(rcfile)
192
-
193
- _run(cli_args)
194
-
195
-
196
- @lazy(name="coverage.html")
197
- def html(
198
- *,
199
- rcfile: str | None = None,
200
- contexts: list[str] | None = None,
201
- directory: str | None = None,
202
- data_file: str | None = None,
203
- fail_under: int | None = None,
204
- ignore_errors: bool | None = None,
205
- include: list[str] | None = None,
206
- omit: list[str] | None = None,
207
- precision: int | None = None,
208
- quiet: bool | None = None,
209
- show_contexts: bool | None = None,
210
- skip_covered: bool | None = None,
211
- skip_empty: bool | None = None,
212
- title: str | None = None,
213
- debug_opts: list[str] | None = None,
214
- ) -> None:
215
- """Create an HTML report.
216
-
217
- Create an HTML report of the coverage of the files. Each file gets its own
218
- page, with the source decorated to show executed, excluded, and missed lines.
219
-
220
- Parameters:
221
- rcfile: Specify configuration file. By default `.coveragerc`, `setup.cfg`, `tox.ini`,
222
- and `pyproject.toml` are tried [env: `COVERAGE_RCFILE`].
223
- contexts: Only display data from lines covered in the given contexts.
224
- Accepts Python regexes, which must be quoted.
225
- directory: Write the output files to this directory.
226
- data_file: Read coverage data for report generation from this file.
227
- Defaults to `.coverage` [env: `COVERAGE_FILE`].
228
- fail_under: Exit with a status of 2 if the total coverage is less than the given number.
229
- ignore_errors: Ignore errors while reading source files.
230
- include: Include only files whose paths match one of these patterns. Accepts shell-style wildcards, which must be quoted.
231
- omit: Omit files whose paths match one of these patterns. Accepts shell-style wildcards, which must be quoted.
232
- precision: Number of digits after the decimal point to display for reported coverage percentages.
233
- quiet: Don't print messages about what is happening.
234
- show_contexts: Show contexts for covered lines.
235
- skip_covered: Skip files with 100% coverage.
236
- skip_empty: Skip files with no code.
237
- title: A text string to use as the title on the HTML.
238
- debug_opts: Debug options, separated by commas [env: `COVERAGE_DEBUG`].
239
- """
240
- cli_args = ["html"]
241
-
242
- if contexts:
243
- cli_args.append("--contexts")
244
- cli_args.append(",".join(contexts))
245
-
246
- if directory:
247
- cli_args.append("--directory")
248
- cli_args.append(directory)
249
-
250
- if data_file:
251
- cli_args.append("--data-file")
252
- cli_args.append(data_file)
253
-
254
- if fail_under is not None:
255
- cli_args.append("--fail-under")
256
- cli_args.append(str(fail_under))
257
-
258
- if ignore_errors:
259
- cli_args.append("--ignore-errors")
260
-
261
- if include:
262
- cli_args.append("--include")
263
- cli_args.append(",".join(include))
264
-
265
- if omit:
266
- cli_args.append("--omit")
267
- cli_args.append(",".join(omit))
268
-
269
- if precision is not None:
270
- cli_args.append("--precision")
271
- cli_args.append(str(precision))
272
-
273
- if quiet:
274
- cli_args.append("--quiet")
275
-
276
- if show_contexts:
277
- cli_args.append("--show-contexts")
278
-
279
- if skip_covered is True:
280
- cli_args.append("--skip-covered")
281
- elif skip_covered is False:
282
- cli_args.append("--no-skip-covered")
283
-
284
- if skip_empty:
285
- cli_args.append("--skip-empty")
286
-
287
- if title:
288
- cli_args.append("--title")
289
- cli_args.append(title)
290
-
291
- if debug_opts:
292
- cli_args.append("--debug")
293
- cli_args.append(",".join(debug_opts))
294
-
295
- if rcfile:
296
- cli_args.append("--rcfile")
297
- cli_args.append(rcfile)
298
-
299
- _run(cli_args)
300
-
301
-
302
- @lazy(name="coverage.json")
303
- def json(
304
- *,
305
- rcfile: str | None = None,
306
- contexts: list[str] | None = None,
307
- data_file: str | None = None,
308
- fail_under: int | None = None,
309
- ignore_errors: bool | None = None,
310
- include: list[str] | None = None,
311
- omit: list[str] | None = None,
312
- output: str | None = None,
313
- pretty_print: bool | None = None,
314
- quiet: bool | None = None,
315
- show_contexts: bool | None = None,
316
- debug_opts: list[str] | None = None,
317
- ) -> None:
318
- """Create a JSON report of coverage results.
319
-
320
- Parameters:
321
- rcfile: Specify configuration file. By default `.coveragerc`, `setup.cfg`, `tox.ini`,
322
- and `pyproject.toml` are tried [env: `COVERAGE_RCFILE`].
323
- contexts: Only display data from lines covered in the given contexts.
324
- Accepts Python regexes, which must be quoted.
325
- data_file: Read coverage data for report generation from this file.
326
- Defaults to `.coverage` [env: `COVERAGE_FILE`].
327
- fail_under: Exit with a status of 2 if the total coverage is less than the given number.
328
- ignore_errors: Ignore errors while reading source files.
329
- include: Include only files whose paths match one of these patterns. Accepts shell-style wildcards, which must be quoted.
330
- omit: Omit files whose paths match one of these patterns. Accepts shell-style wildcards, which must be quoted.
331
- output: Write the JSON report to this file. Defaults to `coverage.json`.
332
- pretty_print: Format the JSON for human readers.
333
- quiet: Don't print messages about what is happening.
334
- show_contexts: Show contexts for covered lines.
335
- debug_opts: Debug options, separated by commas [env: `COVERAGE_DEBUG`].
336
- """
337
- cli_args = ["json"]
338
-
339
- if contexts:
340
- cli_args.append("--contexts")
341
- cli_args.append(",".join(contexts))
342
-
343
- if data_file:
344
- cli_args.append("--data-file")
345
- cli_args.append(data_file)
346
-
347
- if fail_under is not None:
348
- cli_args.append("--fail-under")
349
- cli_args.append(str(fail_under))
350
-
351
- if ignore_errors:
352
- cli_args.append("--ignore-errors")
353
-
354
- if include:
355
- cli_args.append("--include")
356
- cli_args.append(",".join(include))
357
-
358
- if omit:
359
- cli_args.append("--omit")
360
- cli_args.append(",".join(omit))
361
-
362
- if output:
363
- cli_args.append("-o")
364
- cli_args.append(output)
365
-
366
- if pretty_print:
367
- cli_args.append("--pretty-print")
368
-
369
- if quiet:
370
- cli_args.append("--quiet")
371
-
372
- if show_contexts:
373
- cli_args.append("--show-contexts")
374
-
375
- if debug_opts:
376
- cli_args.append("--debug")
377
- cli_args.append(",".join(debug_opts))
378
-
379
- if rcfile:
380
- cli_args.append("--rcfile")
381
- cli_args.append(rcfile)
382
-
383
- _run(cli_args)
384
-
385
-
386
- @lazy(name="coverage.lcov")
387
- def lcov(
388
- *,
389
- rcfile: str | None = None,
390
- data_file: str | None = None,
391
- fail_under: int | None = None,
392
- ignore_errors: bool | None = None,
393
- include: list[str] | None = None,
394
- omit: list[str] | None = None,
395
- output: str | None = None,
396
- quiet: bool | None = None,
397
- debug_opts: list[str] | None = None,
398
- ) -> None:
399
- """Create an LCOV report of coverage results.
400
-
401
- Parameters:
402
- rcfile: Specify configuration file. By default `.coveragerc`, `setup.cfg`, `tox.ini`,
403
- and `pyproject.toml` are tried [env: `COVERAGE_RCFILE`].
404
- data_file: Read coverage data for report generation from this file.
405
- Defaults to `.coverage` [env: `COVERAGE_FILE`].
406
- fail_under: Exit with a status of 2 if the total coverage is less than the given number.
407
- ignore_errors: Ignore errors while reading source files.
408
- include: Include only files whose paths match one of these patterns. Accepts shell-style wildcards, which must be quoted.
409
- omit: Omit files whose paths match one of these patterns. Accepts shell-style wildcards, which must be quoted.
410
- output: Write the JSON report to this file. Defaults to `coverage.json`.
411
- quiet: Don't print messages about what is happening.
412
- debug_opts: Debug options, separated by commas [env: `COVERAGE_DEBUG`].
413
- """
414
- cli_args = ["lcov"]
415
-
416
- if data_file:
417
- cli_args.append("--data-file")
418
- cli_args.append(data_file)
419
-
420
- if fail_under is not None:
421
- cli_args.append("--fail-under")
422
- cli_args.append(str(fail_under))
423
-
424
- if ignore_errors:
425
- cli_args.append("--ignore-errors")
426
-
427
- if include:
428
- cli_args.append("--include")
429
- cli_args.append(",".join(include))
430
-
431
- if omit:
432
- cli_args.append("--omit")
433
- cli_args.append(",".join(omit))
434
-
435
- if output:
436
- cli_args.append("-o")
437
- cli_args.append(output)
438
-
439
- if quiet:
440
- cli_args.append("--quiet")
441
-
442
- if debug_opts:
443
- cli_args.append("--debug")
444
- cli_args.append(",".join(debug_opts))
445
-
446
- if rcfile:
447
- cli_args.append("--rcfile")
448
- cli_args.append(rcfile)
449
-
450
- _run(cli_args)
451
-
452
-
453
- @lazy(name="coverage.report")
454
- def report(
455
- *,
456
- rcfile: str | None = None,
457
- contexts: list[str] | None = None,
458
- data_file: str | None = None,
459
- fail_under: int | None = None,
460
- output_format: Literal["text", "markdown", "total"] | None = None,
461
- ignore_errors: bool | None = None,
462
- include: list[str] | None = None,
463
- omit: list[str] | None = None,
464
- precision: int | None = None,
465
- sort: Literal["name", "stmts", "miss", "branch", "brpart", "cover"] | None = None,
466
- show_missing: bool | None = None,
467
- skip_covered: bool | None = None,
468
- skip_empty: bool | None = None,
469
- debug_opts: list[str] | None = None,
470
- ) -> None:
471
- """Report coverage statistics on modules.
472
-
473
- Parameters:
474
- rcfile: Specify configuration file. By default `.coveragerc`, `setup.cfg`, `tox.ini`,
475
- and `pyproject.toml` are tried [env: `COVERAGE_RCFILE`].
476
- contexts: Only display data from lines covered in the given contexts.
477
- data_file: Read coverage data for report generation from this file.
478
- Defaults to `.coverage` [env: `COVERAGE_FILE`].
479
- fail_under: Exit with a status of 2 if the total coverage is less than the given number.
480
- output_format: Output format, either text (default), markdown, or total.
481
- ignore_errors: Ignore errors while reading source files.
482
- include: Include only files whose paths match one of these patterns. Accepts shell-style wildcards, which must be quoted.
483
- omit: Omit files whose paths match one of these patterns. Accepts shell-style wildcards, which must be quoted.
484
- precision: Number of digits after the decimal point to display for reported coverage percentages.
485
- sort: Sort the report by the named column: name, stmts, miss, branch, brpart, or cover. Default is name.
486
- show_missing: Show line numbers of statements in each module that weren't executed.
487
- skip_covered: Skip files with 100% coverage.
488
- skip_empty: Skip files with no code.
489
- debug_opts: Debug options, separated by commas [env: `COVERAGE_DEBUG`].
490
- """
491
- cli_args = ["report"]
492
-
493
- if contexts:
494
- cli_args.append("--contexts")
495
- cli_args.append(",".join(contexts))
496
-
497
- if data_file:
498
- cli_args.append("--data-file")
499
- cli_args.append(data_file)
500
-
501
- if fail_under is not None:
502
- cli_args.append("--fail-under")
503
- cli_args.append(str(fail_under))
504
-
505
- if output_format:
506
- cli_args.append("--format")
507
- cli_args.append(output_format)
508
-
509
- if ignore_errors:
510
- cli_args.append("--ignore-errors")
511
-
512
- if include:
513
- cli_args.append("--include")
514
- cli_args.append(",".join(include))
515
-
516
- if omit:
517
- cli_args.append("--omit")
518
- cli_args.append(",".join(omit))
519
-
520
- if precision is not None:
521
- cli_args.append("--precision")
522
- cli_args.append(str(precision))
523
-
524
- if sort:
525
- cli_args.append("--sort")
526
- cli_args.append(sort)
527
-
528
- if show_missing:
529
- cli_args.append("--show-missing")
530
-
531
- if skip_covered is True:
532
- cli_args.append("--skip-covered")
533
- elif skip_covered is False:
534
- cli_args.append("--no-skip-covered")
535
-
536
- if skip_empty:
537
- cli_args.append("--skip-empty")
538
-
539
- if debug_opts:
540
- cli_args.append("--debug")
541
- cli_args.append(",".join(debug_opts))
542
-
543
- if rcfile:
544
- cli_args.append("--rcfile")
545
- cli_args.append(rcfile)
546
-
547
- _run(cli_args)
548
-
549
-
550
- @lazy(name="coverage.run")
551
- def run(
552
- pyfile: str,
553
- *,
554
- rcfile: str | None = None,
555
- append: bool | None = None,
556
- branch: bool | None = None,
557
- concurrency: list[str] | None = None,
558
- context: str | None = None,
559
- data_file: str | None = None,
560
- include: list[str] | None = None,
561
- omit: list[str] | None = None,
562
- module: bool | None = None,
563
- pylib: bool | None = None,
564
- parallel_mode: bool | None = None,
565
- source: list[str] | None = None,
566
- timid: bool | None = None,
567
- debug_opts: list[str] | None = None,
568
- ) -> None:
569
- """Run a Python program and measure code execution.
570
-
571
- Parameters:
572
- pyfile: Python script or module to run.
573
- rcfile: Specify configuration file. By default `.coveragerc`, `setup.cfg`, `tox.ini`,
574
- and `pyproject.toml` are tried [env: `COVERAGE_RCFILE`].
575
- append: Append coverage data to .coverage, otherwise it starts clean each time.
576
- branch: Measure branch coverage in addition to statement coverage.
577
- concurrency: Properly measure code using a concurrency library. Valid values are:
578
- eventlet, gevent, greenlet, multiprocessing, thread, or a comma-list of them.
579
- context: The context label to record for this coverage run.
580
- data_file: Read coverage data for report generation from this file.
581
- Defaults to `.coverage` [env: `COVERAGE_FILE`].
582
- include: Include only files whose paths match one of these patterns. Accepts shell-style wildcards, which must be quoted.
583
- omit: Omit files whose paths match one of these patterns. Accepts shell-style wildcards, which must be quoted.
584
- module: The given file is an importable Python module, not a script path, to be run as `python -m` would run it.
585
- pylib: Measure coverage even inside the Python installed library, which isn't done by default.
586
- parallel_mode: Append the machine name, process id and random number to the data file name
587
- to simplify collecting data from many processes.
588
- source: A list of directories or importable names of code to measure.
589
- timid: Use a simpler but slower trace method. Try this if you get seemingly impossible results!
590
- debug_opts: Debug options, separated by commas [env: `COVERAGE_DEBUG`].
591
- """
592
- cli_args = ["run", pyfile]
593
-
594
- if append:
595
- cli_args.append("--append")
596
-
597
- if branch:
598
- cli_args.append("--branch")
599
-
600
- if concurrency:
601
- cli_args.append("--concurrency")
602
- cli_args.append(",".join(concurrency))
603
-
604
- if context:
605
- cli_args.append("--context")
606
- cli_args.append(context)
607
-
608
- if data_file:
609
- cli_args.append("--data-file")
610
- cli_args.append(data_file)
611
-
612
- if include:
613
- cli_args.append("--include")
614
- cli_args.append(",".join(include))
615
-
616
- if omit:
617
- cli_args.append("--omit")
618
- cli_args.append(",".join(omit))
619
-
620
- if module:
621
- cli_args.append("--module")
622
-
623
- if pylib:
624
- cli_args.append("--pylib")
625
-
626
- if parallel_mode:
627
- cli_args.append("--parallel-mode")
628
-
629
- if source:
630
- cli_args.append("--source")
631
- cli_args.append(",".join(source))
632
-
633
- if timid:
634
- cli_args.append("--timid")
635
-
636
- if debug_opts:
637
- cli_args.append("--debug")
638
- cli_args.append(",".join(debug_opts))
639
-
640
- if rcfile:
641
- cli_args.append("--rcfile")
642
- cli_args.append(rcfile)
643
-
644
- _run(cli_args)
645
-
646
-
647
- @lazy(name="coverage.xml")
648
- def xml(
649
- *,
650
- rcfile: str | None = None,
651
- data_file: str | None = None,
652
- fail_under: int | None = None,
653
- ignore_errors: bool | None = None,
654
- include: list[str] | None = None,
655
- omit: list[str] | None = None,
656
- output: str | None = None,
657
- quiet: bool | None = None,
658
- skip_empty: bool | None = None,
659
- debug_opts: list[str] | None = None,
660
- ) -> None:
661
- """Create an XML report of coverage results.
662
-
663
- Parameters:
664
- rcfile: Specify configuration file. By default `.coveragerc`, `setup.cfg`, `tox.ini`,
665
- and `pyproject.toml` are tried [env: `COVERAGE_RCFILE`].
666
- data_file: Read coverage data for report generation from this file.
667
- Defaults to `.coverage` [env: `COVERAGE_FILE`].
668
- fail_under: Exit with a status of 2 if the total coverage is less than the given number.
669
- ignore_errors: Ignore errors while reading source files.
670
- include: Include only files whose paths match one of these patterns. Accepts shell-style wildcards, which must be quoted.
671
- omit: Omit files whose paths match one of these patterns. Accepts shell-style wildcards, which must be quoted.
672
- output: Write the JSON report to this file. Defaults to `coverage.json`.
673
- quiet: Don't print messages about what is happening.
674
- skip_empty: Skip files with no code.
675
- debug_opts: Debug options, separated by commas [env: `COVERAGE_DEBUG`].
676
- """
677
- cli_args = ["xml"]
678
-
679
- if data_file:
680
- cli_args.append("--data-file")
681
- cli_args.append(data_file)
682
-
683
- if fail_under is not None:
684
- cli_args.append("--fail-under")
685
- cli_args.append(str(fail_under))
686
-
687
- if ignore_errors:
688
- cli_args.append("--ignore-errors")
689
-
690
- if include:
691
- cli_args.append("--include")
692
- cli_args.append(",".join(include))
693
-
694
- if omit:
695
- cli_args.append("--omit")
696
- cli_args.append(",".join(omit))
697
-
698
- if output:
699
- cli_args.append("-o")
700
- cli_args.append(output)
701
-
702
- if quiet:
703
- cli_args.append("--quiet")
704
-
705
- if skip_empty:
706
- cli_args.append("--skip-empty")
707
-
708
- if debug_opts:
709
- cli_args.append("--debug")
710
- cli_args.append(",".join(debug_opts))
711
-
712
- if rcfile:
713
- cli_args.append("--rcfile")
714
- cli_args.append(rcfile)
715
-
716
- _run(cli_args)
11
+ def __getattr__(name: str) -> Any:
12
+ warnings.warn(
13
+ "Callables are deprecated in favor of tools, use `duty.tools.coverage` instead of `duty.callables.coverage`.",
14
+ DeprecationWarning,
15
+ stacklevel=2,
16
+ )
17
+ return getattr(_coverage, name)