griffecli 2.1.0__tar.gz → 2.3.0__tar.gz

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.
@@ -5,6 +5,58 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5
5
  and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
6
 
7
7
  <!-- insertion marker -->
8
+ ## [2.3.0](https://github.com/mkdocstrings/griffe/releases/tag/2.3.0) - 2026-09-04
9
+
10
+ <small>[Compare with 2.2.0](https://github.com/mkdocstrings/griffe/compare/2.2.0...2.3.0)</small>
11
+
12
+ ### Features
13
+
14
+ - Add option to give precedence to docstrings in stubs vs. source ([09a2a13](https://github.com/mkdocstrings/griffe/commit/09a2a1323d1b4d022a4ce76a9f2839287b9c100e) by Timothée Mazzucotelli). [Issue-447](https://github.com/mkdocstrings/griffe/issues/447), [PR-481](https://github.com/mkdocstrings/griffe/pull/481)
15
+
16
+ ### Bug Fixes
17
+
18
+ - Preserve nested tuple parentheses ([e095a7c](https://github.com/mkdocstrings/griffe/commit/e095a7cd4c239abd961f7899d7ddb17ea27caead) by Alperen). [PR-487](https://github.com/mkdocstrings/griffe/pull/487), Co-authored-by: Timothée Mazzucotelli <dev@pawamoy.fr>
19
+ - Preserve nested f-string format specs ([38921b7](https://github.com/mkdocstrings/griffe/commit/38921b70e3dbba9a493aa5117f11a3a7883634cf) by Alperen). [PR-486](https://github.com/mkdocstrings/griffe/pull/486)
20
+ - Disable all docstring warnings when passing `warnings=False` ([5cb0ae2](https://github.com/mkdocstrings/griffe/commit/5cb0ae2f00748288c4009c1d4b6ee19f6aca6b76) by Timothée Mazzucotelli).
21
+
22
+ ### Performance Improvements
23
+
24
+ - Reuse computed parent in `is_imported` ([092ac31](https://github.com/mkdocstrings/griffe/commit/092ac3162e1477a4b62eb875365996998adbd77d) by Timothée Mazzucotelli).
25
+ - Only build debug messages at debug level ([8f05a4a](https://github.com/mkdocstrings/griffe/commit/8f05a4ae5587d685bea1b0c98294a047b56c8df0) by Timothée Mazzucotelli).
26
+ - Avoid creating new sets when handling labels ([06cd02e](https://github.com/mkdocstrings/griffe/commit/06cd02e63c240286d11450887cc01b0ef76d8908) by Timothée Mazzucotelli).
27
+ - Maintain map of AST node type to visitor function ([e21851e](https://github.com/mkdocstrings/griffe/commit/e21851e732782823006223a7f5f8111b4200a257) by Timothée Mazzucotelli).
28
+ - Avoid cyclic refs in ASTs to allow garbage-collecting them ([b968de0](https://github.com/mkdocstrings/griffe/commit/b968de091afc1a4fd241f457538433ce3ada7520) by Timothée Mazzucotelli).
29
+ - Cache per-module path-related properties during serialization ([8bd6cc4](https://github.com/mkdocstrings/griffe/commit/8bd6cc4b34e96fc8235271cfa93a1a6a77091707) by Timothée Mazzucotelli).
30
+ - Do not fire load events when no extension has hooked them ([0e2ae7c](https://github.com/mkdocstrings/griffe/commit/0e2ae7c8cd1563d6dcca7a6c37fb8f2ec072cb24) by Timothée Mazzucotelli).
31
+ - Compute costly message lazily in alias resolution errors ([1e391b8](https://github.com/mkdocstrings/griffe/commit/1e391b8239747bb62908819e55468a961ffbaa99) by Timothée Mazzucotelli).
32
+ - Avoid iterating many times over function parameters when merging stubs ([03cae74](https://github.com/mkdocstrings/griffe/commit/03cae743e02c56af7375ffbfa70d6acf02e5491d) by Timothée Mazzucotelli).
33
+ - Avoid iterating many times over function parameters when diff'ing ([d3cf2c4](https://github.com/mkdocstrings/griffe/commit/d3cf2c41bb5f734e57b612b42d178e87af605ae8) by Timothée Mazzucotelli).
34
+ - Improve efficiency of AST parameter extraction ([1e37cd4](https://github.com/mkdocstrings/griffe/commit/1e37cd488d6adf55065b3ce4e7932faf1ff7d186) by Timothée Mazzucotelli).
35
+ - Cache serializable expression fields ([f9e48c1](https://github.com/mkdocstrings/griffe/commit/f9e48c16ebaeb719d5768cb921637aebe377a639) by Timothée Mazzucotelli).
36
+ - Use maps to make JSON encoder faster ([b7de96f](https://github.com/mkdocstrings/griffe/commit/b7de96fb516218ae3bf6a8e6d014a223df67f4a3) by Timothée Mazzucotelli).
37
+ - Avoid recomputing inherited members when diff'ing ([a29e028](https://github.com/mkdocstrings/griffe/commit/a29e028ff034752ff747dda17f3f875f22c2a192) by Timothée Mazzucotelli).
38
+ - Make Google, Numpy and Sphinx docstring parsers faster ([7f39373](https://github.com/mkdocstrings/griffe/commit/7f39373f8da779fb104dd2b6c11a02d95da628c4) by Timothée Mazzucotelli).
39
+ - Pre-compile patterns for docstring style detection ([ad58ad5](https://github.com/mkdocstrings/griffe/commit/ad58ad5b86390a8a02311189315dd4f59e0300a4) by Timothée Mazzucotelli).
40
+ - LRU-cache parsing of type annotations in docstrings ([1671e59](https://github.com/mkdocstrings/griffe/commit/1671e59fb675e9b45338956ce8aa5f5e56692690) by Timothée Mazzucotelli).
41
+
42
+ ## [2.2.0](https://github.com/mkdocstrings/griffe/releases/tag/2.2.0) - 2026-08-16
43
+
44
+ <small>[Compare with 2.1.0](https://github.com/mkdocstrings/griffe/compare/2.1.0...2.2.0)</small>
45
+
46
+ ### Features
47
+
48
+ - Support `await` expressions ([6b3caab](https://github.com/mkdocstrings/griffe/commit/6b3caab7ce4fdcb1c9386937dad17510d35a3321) by Vincent Gao). [PR-479](https://github.com/mkdocstrings/griffe/pull/479)
49
+ - Support unpacking in dict comprehensions ([2d39391](https://github.com/mkdocstrings/griffe/commit/2d39391cb135febadf339bdea91c1113b74da145) by mushitoriami). [PR-475](https://github.com/mkdocstrings/griffe/pull/475)
50
+
51
+ ### Bug Fixes
52
+
53
+ - Forward `warn_missing_types` to Sphinx return section reader ([a15e782](https://github.com/mkdocstrings/griffe/commit/a15e782ed0793e06d22105beb016c10cfe0ed4b0) by Timothée Mazzucotelli). [Issue-mkdocstrings-python-337](https://github.com/mkdocstrings/python/issues/337)
54
+ - Make stringified expressions valid and faithful Python ([eb85f0d](https://github.com/mkdocstrings/griffe/commit/eb85f0dd8bf49f4a2400bf03face646d8f533a7c) by Vincent Gao). [PR-478](https://github.com/mkdocstrings/griffe/pull/478)
55
+ - Empty tuples can never be implicit ([82e728d](https://github.com/mkdocstrings/griffe/commit/82e728dc758f9635d2e500c13caa795b48e36d8a) by Vincent Gao). [PR-474](https://github.com/mkdocstrings/griffe/pull/474), Co-authored-by: Timothée Mazzucotelli <dev@pawamoy.fr>
56
+ - Render f-strings and t-strings with correct quote delimiters ([90e28d4](https://github.com/mkdocstrings/griffe/commit/90e28d45ffc998434895c0f73af608cb12f0d6dd) by Bartosz Sławecki). [Issue-444](https://github.com/mkdocstrings/griffe/issues/444), [PR-455](https://github.com/mkdocstrings/griffe/pull/455)
57
+ - Detect basic admonitions 'example', 'note' and 'warning' in Google/Numpy docstrings when inferring style ([f30306f](https://github.com/mkdocstrings/griffe/commit/f30306fa703741f976fc49576ddf95cf29ba998b) by Timothée Mazzucotelli).
58
+ - Render dict `**`-unpacking as `**value` instead of `None: value` ([74ddbbf](https://github.com/mkdocstrings/griffe/commit/74ddbbf22f49e1fb789ac754e3fff41a0ac2f152) by Vincent Gao). [PR-467](https://github.com/mkdocstrings/griffe/pull/467)
59
+
8
60
  ## [2.1.0](https://github.com/mkdocstrings/griffe/releases/tag/2.1.0) - 2026-06-19
9
61
 
10
62
  <small>[Compare with 2.0.2](https://github.com/mkdocstrings/griffe/compare/2.0.2...2.1.0)</small>
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.5
2
2
  Name: griffecli
3
- Version: 2.1.0
3
+ Version: 2.3.0
4
4
  Summary: Signatures for entire Python programs. Extract the structure, the frame, the skeleton of your project, to generate API documentation or find breaking changes in your API.
5
5
  Author-email: Timothée Mazzucotelli <dev@pawamoy.fr>
6
6
  License-Expression: ISC
@@ -22,4 +22,4 @@ Classifier: Topic :: Utilities
22
22
  Classifier: Typing :: Typed
23
23
  Requires-Python: >=3.10
24
24
  Requires-Dist: colorama>=0.4
25
- Requires-Dist: griffelib==2.1.0
25
+ Requires-Dist: griffelib==2.3.0
@@ -143,7 +143,7 @@ See the [Loading chapter](https://mkdocstrings.github.io/griffe/guide/users/load
143
143
  <a href="https://github.com/BenHammersley"><img alt="BenHammersley" src="https://avatars.githubusercontent.com/u/99436?u=4499a7b507541045222ee28ae122dbe3c8d08ab5&v=4" style="height: 32px; border-radius: 100%;"></a>
144
144
  <a href="https://github.com/trevorWieland"><img alt="trevorWieland" src="https://avatars.githubusercontent.com/u/28811461?u=74cc0e3756c1d4e3d66b5c396e1d131ea8a10472&v=4" style="height: 32px; border-radius: 100%;"></a>
145
145
  <a href="https://github.com/MarcoGorelli"><img alt="MarcoGorelli" src="https://avatars.githubusercontent.com/u/33491632?u=7de3a749cac76a60baca9777baf71d043a4f884d&v=4" style="height: 32px; border-radius: 100%;"></a>
146
- <a href="https://github.com/analog-cbarber"><img alt="analog-cbarber" src="https://avatars.githubusercontent.com/u/7408243?u=642fc2bdcc9904089c62fe5aec4e03ace32da67d&v=4" style="height: 32px; border-radius: 100%;"></a>
146
+ <a href="https://github.com/analog-cbarber"><img alt="analog-cbarber" src="https://avatars.githubusercontent.com/u/7408243?u=fe0e7bf2882d1c9c901a341c2502e1518466527a&v=4" style="height: 32px; border-radius: 100%;"></a>
147
147
  <a href="https://github.com/OdinManiac"><img alt="OdinManiac" src="https://avatars.githubusercontent.com/u/22727172?u=36ab20970f7f52ae8e7eb67b7fcf491fee01ac22&v=4" style="height: 32px; border-radius: 100%;"></a>
148
148
  <a href="https://github.com/rstudio-sponsorship"><img alt="rstudio-sponsorship" src="https://avatars.githubusercontent.com/u/58949051?u=0c471515dd18111be30dfb7669ed5e778970959b&v=4" style="height: 32px; border-radius: 100%;"></a>
149
149
  <a href="https://github.com/schlich"><img alt="schlich" src="https://avatars.githubusercontent.com/u/21191435?u=6f1240adb68f21614d809ae52d66509f46b1e877&v=4" style="height: 32px; border-radius: 100%;"></a>
@@ -155,17 +155,15 @@ See the [Loading chapter](https://mkdocstrings.github.io/griffe/guide/users/load
155
155
  <a href="https://github.com/activeloopai"><img alt="activeloopai" src="https://avatars.githubusercontent.com/u/34816118?v=4" style="height: 32px; border-radius: 100%;"></a>
156
156
  <a href="https://github.com/roboflow"><img alt="roboflow" src="https://avatars.githubusercontent.com/u/53104118?v=4" style="height: 32px; border-radius: 100%;"></a>
157
157
  <a href="https://github.com/cmclaughlin"><img alt="cmclaughlin" src="https://avatars.githubusercontent.com/u/1061109?u=ddf6eec0edd2d11c980f8c3aa96e3d044d4e0468&v=4" style="height: 32px; border-radius: 100%;"></a>
158
- <a href="https://github.com/blaisep"><img alt="blaisep" src="https://avatars.githubusercontent.com/u/254456?u=97d584b7c0a6faf583aa59975df4f993f671d121&v=4" style="height: 32px; border-radius: 100%;"></a>
159
158
  <a href="https://github.com/RapidataAI"><img alt="RapidataAI" src="https://avatars.githubusercontent.com/u/104209891?v=4" style="height: 32px; border-radius: 100%;"></a>
160
159
  <a href="https://github.com/rodolphebarbanneau"><img alt="rodolphebarbanneau" src="https://avatars.githubusercontent.com/u/46493454?u=6c405452a40c231cdf0b68e97544e07ee956a733&v=4" style="height: 32px; border-radius: 100%;"></a>
161
160
  <a href="https://github.com/theSymbolSyndicate"><img alt="theSymbolSyndicate" src="https://avatars.githubusercontent.com/u/111542255?v=4" style="height: 32px; border-radius: 100%;"></a>
162
161
  <a href="https://github.com/blakeNaccarato"><img alt="blakeNaccarato" src="https://avatars.githubusercontent.com/u/20692450?u=bb919218be30cfa994514f4cf39bb2f7cf952df4&v=4" style="height: 32px; border-radius: 100%;"></a>
163
162
  <a href="https://github.com/ChargeStorm"><img alt="ChargeStorm" src="https://avatars.githubusercontent.com/u/26000165?v=4" style="height: 32px; border-radius: 100%;"></a>
164
- <a href="https://github.com/Alphadelta14"><img alt="Alphadelta14" src="https://avatars.githubusercontent.com/u/480845?v=4" style="height: 32px; border-radius: 100%;"></a>
165
163
  <a href="https://github.com/Cusp-AI"><img alt="Cusp-AI" src="https://avatars.githubusercontent.com/u/178170649?v=4" style="height: 32px; border-radius: 100%;"></a>
166
164
  </p></div>
167
165
 
168
166
 
169
- *And 7 more private sponsor(s).*
167
+ *And 4 more private sponsor(s).*
170
168
 
171
169
  <!-- sponsors-end -->
@@ -0,0 +1,43 @@
1
+ # SPDX-License-Identifier: ISC
2
+
3
+ # Copyright (c) 2021, Timothée Mazzucotelli and contributors
4
+
5
+ # Permission to use, copy, modify, and/or distribute this software for any
6
+ # purpose with or without fee is hereby granted, provided that the above
7
+ # copyright notice and this permission notice appear in all copies.
8
+
9
+ # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
+ # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16
+
17
+ # This top-level module imports all public names from the CLI package,
18
+ # and exposes them as public objects.
19
+
20
+ """Griffe CLI package.
21
+
22
+ The CLI (Command Line Interface) for the griffe library.
23
+ This package provides command-line tools for interacting with griffe.
24
+
25
+ ## CLI entrypoints
26
+
27
+ - [`griffecli.main`][]: Run the main program.
28
+ - [`griffecli.check`][]: Check for API breaking changes in two versions of the same package.
29
+ - [`griffecli.dump`][]: Load packages data and dump it as JSON.
30
+ - [`griffecli.get_parser`][]: Get the argument parser for the CLI.
31
+ """
32
+
33
+ from __future__ import annotations
34
+
35
+ from griffecli._internal.cli import DEFAULT_LOG_LEVEL, check, dump, get_parser, main
36
+
37
+ __all__ = [
38
+ "DEFAULT_LOG_LEVEL",
39
+ "check",
40
+ "dump",
41
+ "get_parser",
42
+ "main",
43
+ ]
@@ -0,0 +1,29 @@
1
+ # SPDX-License-Identifier: ISC
2
+
3
+ # Copyright (c) 2021, Timothée Mazzucotelli and contributors
4
+
5
+ # Permission to use, copy, modify, and/or distribute this software for any
6
+ # purpose with or without fee is hereby granted, provided that the above
7
+ # copyright notice and this permission notice appear in all copies.
8
+
9
+ # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
+ # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16
+
17
+ # Entry-point module, in case you use `python -m griffecli`.
18
+ #
19
+ # Why does this file exist, and why `__main__`? For more info, read:
20
+ #
21
+ # - https://www.python.org/dev/peps/pep-0338/
22
+ # - https://docs.python.org/3/using/cmdline.html#cmdoption-m
23
+
24
+ import sys
25
+
26
+ from griffecli._internal.cli import main
27
+
28
+ if __name__ == "__main__":
29
+ sys.exit(main(sys.argv[1:]))
@@ -0,0 +1,17 @@
1
+ # SPDX-License-Identifier: ISC
2
+
3
+ # Copyright (c) 2021, Timothée Mazzucotelli and contributors
4
+
5
+ # Permission to use, copy, modify, and/or distribute this software for any
6
+ # purpose with or without fee is hereby granted, provided that the above
7
+ # copyright notice and this permission notice appear in all copies.
8
+
9
+ # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
+ # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16
+
17
+ # Internal modules for the griffecli package.
@@ -1,3 +1,19 @@
1
+ # SPDX-License-Identifier: ISC
2
+
3
+ # Copyright (c) 2021, Timothée Mazzucotelli and contributors
4
+
5
+ # Permission to use, copy, modify, and/or distribute this software for any
6
+ # purpose with or without fee is hereby granted, provided that the above
7
+ # copyright notice and this permission notice appear in all copies.
8
+
9
+ # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
+ # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16
+
1
17
  # This module contains all CLI-related things.
2
18
  # Why does this file exist, and why not put this in `__main__`?
3
19
  #
@@ -75,6 +91,7 @@ def _load_packages(
75
91
  force_inspection: bool = False,
76
92
  store_source: bool = True,
77
93
  find_stubs_package: bool = False,
94
+ prefer_stubs_docs: bool = False,
78
95
  ) -> GriffeLoader:
79
96
  from griffe._internal.loader import GriffeLoader # noqa: PLC0415
80
97
  from griffe._internal.logger import logger # noqa: PLC0415
@@ -88,6 +105,7 @@ def _load_packages(
88
105
  allow_inspection=allow_inspection,
89
106
  force_inspection=force_inspection,
90
107
  store_source=store_source,
108
+ prefer_stubs_docs=prefer_stubs_docs,
91
109
  )
92
110
 
93
111
  # Load each package.
@@ -176,6 +194,14 @@ def get_parser() -> argparse.ArgumentParser:
176
194
  default=False,
177
195
  help="Whether to look for stubs-only packages and merge them with concrete ones.",
178
196
  )
197
+ loading_options.add_argument(
198
+ "-P",
199
+ "--prefer-stubs-docstrings",
200
+ dest="prefer_stubs_docs",
201
+ action="store_true",
202
+ default=False,
203
+ help="Whether to prefer docstrings from stubs over those from sources.",
204
+ )
179
205
  loading_options.add_argument(
180
206
  "-e",
181
207
  "--extensions",
@@ -342,6 +368,7 @@ def dump(
342
368
  resolve_external: bool | None = None,
343
369
  search_paths: Sequence[str | Path] | None = None,
344
370
  find_stubs_package: bool = False,
371
+ prefer_stubs_docs: bool = False,
345
372
  append_sys_path: bool = False,
346
373
  allow_inspection: bool = True,
347
374
  force_inspection: bool = False,
@@ -364,6 +391,7 @@ def dump(
364
391
  find_stubs_package: Whether to search for stubs-only packages.
365
392
  If both the package and its stubs are found, they'll be merged together.
366
393
  If only the stubs are found, they'll be used as the package itself.
394
+ prefer_stubs_docs: Whether to give precedence to docstrings from stubs over those from sources.
367
395
  append_sys_path: Whether to append the contents of `sys.path` to the search paths.
368
396
  allow_inspection: Whether to allow inspecting modules when visiting them is not possible.
369
397
  force_inspection: Whether to force using dynamic analysis when loading data.
@@ -406,6 +434,7 @@ def dump(
406
434
  force_inspection=force_inspection,
407
435
  store_source=False,
408
436
  find_stubs_package=find_stubs_package,
437
+ prefer_stubs_docs=prefer_stubs_docs,
409
438
  )
410
439
  data_packages = loader.modules_collection.members
411
440
 
@@ -438,6 +467,7 @@ def check(
438
467
  search_paths: Sequence[str | Path] | None = None,
439
468
  append_sys_path: bool = False,
440
469
  find_stubs_package: bool = False,
470
+ prefer_stubs_docs: bool = False,
441
471
  allow_inspection: bool = True,
442
472
  force_inspection: bool = False,
443
473
  verbose: bool = False,
@@ -454,6 +484,8 @@ def check(
454
484
  extensions: The extensions to use.
455
485
  search_paths: The paths to search into.
456
486
  append_sys_path: Whether to append the contents of `sys.path` to the search paths.
487
+ find_stubs_package: Whether to search for stubs-only packages.
488
+ prefer_stubs_docs: Whether to give precedence to docstrings from stubs over those from sources.
457
489
  allow_inspection: Whether to allow inspecting modules when visiting them is not possible.
458
490
  force_inspection: Whether to force using dynamic analysis when loading data.
459
491
  verbose: Use a verbose output.
@@ -493,6 +525,7 @@ def check(
493
525
  allow_inspection=allow_inspection,
494
526
  force_inspection=force_inspection,
495
527
  find_stubs_package=find_stubs_package,
528
+ prefer_stubs_docs=prefer_stubs_docs,
496
529
  resolve_aliases=True,
497
530
  resolve_external=None,
498
531
  )
@@ -514,6 +547,7 @@ def check(
514
547
  allow_inspection=allow_inspection,
515
548
  force_inspection=force_inspection,
516
549
  find_stubs_package=find_stubs_package,
550
+ prefer_stubs_docs=prefer_stubs_docs,
517
551
  resolve_aliases=True,
518
552
  resolve_external=None,
519
553
  )
@@ -537,6 +571,7 @@ def check(
537
571
  allow_inspection=allow_inspection,
538
572
  force_inspection=force_inspection,
539
573
  find_stubs_package=find_stubs_package,
574
+ prefer_stubs_docs=prefer_stubs_docs,
540
575
  resolve_aliases=True,
541
576
  resolve_external=None,
542
577
  )
@@ -551,6 +586,7 @@ def check(
551
586
  allow_inspection=allow_inspection,
552
587
  force_inspection=force_inspection,
553
588
  find_stubs_package=find_stubs_package,
589
+ prefer_stubs_docs=prefer_stubs_docs,
554
590
  resolve_aliases=True,
555
591
  resolve_external=None,
556
592
  )
@@ -563,6 +599,7 @@ def check(
563
599
  allow_inspection=allow_inspection,
564
600
  force_inspection=force_inspection,
565
601
  find_stubs_package=find_stubs_package,
602
+ prefer_stubs_docs=prefer_stubs_docs,
566
603
  resolve_aliases=True,
567
604
  resolve_external=None,
568
605
  )
@@ -0,0 +1,17 @@
1
+ # SPDX-License-Identifier: ISC
2
+
3
+ # Copyright (c) 2021, Timothée Mazzucotelli and contributors
4
+
5
+ # Permission to use, copy, modify, and/or distribute this software for any
6
+ # purpose with or without fee is hereby granted, provided that the above
7
+ # copyright notice and this permission notice appear in all copies.
8
+
9
+ # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
+ # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16
+
17
+ """Tests suite for `griffecli`."""
@@ -0,0 +1,98 @@
1
+ # SPDX-License-Identifier: ISC
2
+
3
+ # Copyright (c) 2021, Timothée Mazzucotelli and contributors
4
+
5
+ # Permission to use, copy, modify, and/or distribute this software for any
6
+ # purpose with or without fee is hereby granted, provided that the above
7
+ # copyright notice and this permission notice appear in all copies.
8
+
9
+ # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
+ # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16
+
17
+ """Tests for the CLI."""
18
+
19
+ from __future__ import annotations
20
+
21
+ import json
22
+ import sys
23
+ from typing import TYPE_CHECKING
24
+
25
+ import pytest
26
+
27
+ from griffe._internal import debug
28
+ from griffecli._internal import cli
29
+
30
+ if TYPE_CHECKING:
31
+ from pathlib import Path
32
+
33
+
34
+ def test_main() -> None:
35
+ """Basic CLI test."""
36
+ if sys.platform == "win32":
37
+ assert cli.main(["dump", "griffe", "-s", "src", "-oNUL"]) == 0
38
+ else:
39
+ assert cli.main(["dump", "griffe", "-s", "src", "-o/dev/null"]) == 0
40
+
41
+
42
+ @pytest.mark.parametrize("flag", ["-P", "--prefer-stubs-docstrings"])
43
+ def test_prefer_stubs_docstrings(tmp_path: Path, flag: str) -> None:
44
+ """Prefer docstrings from stubs when requested.
45
+
46
+ Parameters:
47
+ tmp_path: Pytest fixture providing a temporary directory.
48
+ flag: Short or long spelling of the CLI flag.
49
+ """
50
+ package_path = tmp_path / "package"
51
+ package_path.mkdir()
52
+ package_path.joinpath("__init__.py").write_text('"""Source."""', encoding="utf8")
53
+ package_path.joinpath("__init__.pyi").write_text('"""Stubs."""', encoding="utf8")
54
+ output_path = tmp_path / "output.json"
55
+
56
+ assert cli.main(["dump", str(package_path), flag, "-o", str(output_path)]) == 0
57
+
58
+ output = json.loads(output_path.read_text(encoding="utf8"))
59
+ assert output["package"]["docstring"]["value"] == "Stubs."
60
+
61
+
62
+ def test_show_help(capsys: pytest.CaptureFixture) -> None:
63
+ """Show help.
64
+
65
+ Parameters:
66
+ capsys: Pytest fixture to capture output.
67
+ """
68
+ with pytest.raises(SystemExit):
69
+ cli.main(["-h"])
70
+ captured = capsys.readouterr()
71
+ assert "griffe" in captured.out
72
+
73
+
74
+ def test_show_version(capsys: pytest.CaptureFixture) -> None:
75
+ """Show version.
76
+
77
+ Parameters:
78
+ capsys: Pytest fixture to capture output.
79
+ """
80
+ with pytest.raises(SystemExit):
81
+ cli.main(["-V"])
82
+ captured = capsys.readouterr()
83
+ assert debug._get_version() in captured.out
84
+
85
+
86
+ def test_show_debug_info(capsys: pytest.CaptureFixture) -> None:
87
+ """Show debug information.
88
+
89
+ Parameters:
90
+ capsys: Pytest fixture to capture output.
91
+ """
92
+ with pytest.raises(SystemExit):
93
+ cli.main(["--debug-info"])
94
+ captured = capsys.readouterr().out.lower()
95
+ assert "python" in captured
96
+ assert "system" in captured
97
+ assert "environment" in captured
98
+ assert "packages" in captured
@@ -1,27 +0,0 @@
1
- # This top-level module imports all public names from the CLI package,
2
- # and exposes them as public objects.
3
-
4
- """Griffe CLI package.
5
-
6
- The CLI (Command Line Interface) for the griffe library.
7
- This package provides command-line tools for interacting with griffe.
8
-
9
- ## CLI entrypoints
10
-
11
- - [`griffecli.main`][]: Run the main program.
12
- - [`griffecli.check`][]: Check for API breaking changes in two versions of the same package.
13
- - [`griffecli.dump`][]: Load packages data and dump it as JSON.
14
- - [`griffecli.get_parser`][]: Get the argument parser for the CLI.
15
- """
16
-
17
- from __future__ import annotations
18
-
19
- from griffecli._internal.cli import DEFAULT_LOG_LEVEL, check, dump, get_parser, main
20
-
21
- __all__ = [
22
- "DEFAULT_LOG_LEVEL",
23
- "check",
24
- "dump",
25
- "get_parser",
26
- "main",
27
- ]
@@ -1,13 +0,0 @@
1
- # Entry-point module, in case you use `python -m griffecli`.
2
- #
3
- # Why does this file exist, and why `__main__`? For more info, read:
4
- #
5
- # - https://www.python.org/dev/peps/pep-0338/
6
- # - https://docs.python.org/3/using/cmdline.html#cmdoption-m
7
-
8
- import sys
9
-
10
- from griffecli._internal.cli import main
11
-
12
- if __name__ == "__main__":
13
- sys.exit(main(sys.argv[1:]))
@@ -1 +0,0 @@
1
- # Internal modules for the griffecli package.
@@ -1 +0,0 @@
1
- """Tests suite for `griffecli`."""
@@ -1,57 +0,0 @@
1
- """Tests for the CLI."""
2
-
3
- from __future__ import annotations
4
-
5
- import sys
6
-
7
- import pytest
8
-
9
- from griffe._internal import debug
10
- from griffecli._internal import cli
11
-
12
-
13
- def test_main() -> None:
14
- """Basic CLI test."""
15
- if sys.platform == "win32":
16
- assert cli.main(["dump", "griffe", "-s", "src", "-oNUL"]) == 0
17
- else:
18
- assert cli.main(["dump", "griffe", "-s", "src", "-o/dev/null"]) == 0
19
-
20
-
21
- def test_show_help(capsys: pytest.CaptureFixture) -> None:
22
- """Show help.
23
-
24
- Parameters:
25
- capsys: Pytest fixture to capture output.
26
- """
27
- with pytest.raises(SystemExit):
28
- cli.main(["-h"])
29
- captured = capsys.readouterr()
30
- assert "griffe" in captured.out
31
-
32
-
33
- def test_show_version(capsys: pytest.CaptureFixture) -> None:
34
- """Show version.
35
-
36
- Parameters:
37
- capsys: Pytest fixture to capture output.
38
- """
39
- with pytest.raises(SystemExit):
40
- cli.main(["-V"])
41
- captured = capsys.readouterr()
42
- assert debug._get_version() in captured.out
43
-
44
-
45
- def test_show_debug_info(capsys: pytest.CaptureFixture) -> None:
46
- """Show debug information.
47
-
48
- Parameters:
49
- capsys: Pytest fixture to capture output.
50
- """
51
- with pytest.raises(SystemExit):
52
- cli.main(["--debug-info"])
53
- captured = capsys.readouterr().out.lower()
54
- assert "python" in captured
55
- assert "system" in captured
56
- assert "environment" in captured
57
- assert "packages" in captured
File without changes
File without changes
File without changes