griffecli 2.2.0__tar.gz → 2.3.1__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.
- {griffecli-2.2.0 → griffecli-2.3.1}/.gitignore +5 -0
- {griffecli-2.2.0 → griffecli-2.3.1}/CHANGELOG.md +46 -0
- {griffecli-2.2.0 → griffecli-2.3.1}/LICENSE +1 -1
- {griffecli-2.2.0 → griffecli-2.3.1}/PKG-INFO +2 -3
- {griffecli-2.2.0 → griffecli-2.3.1}/README.md +1 -1
- {griffecli-2.2.0 → griffecli-2.3.1}/pyproject.toml +0 -2
- {griffecli-2.2.0 → griffecli-2.3.1}/src/griffecli/_internal/cli.py +28 -3
- {griffecli-2.2.0 → griffecli-2.3.1}/tests/test_cli.py +25 -0
- {griffecli-2.2.0 → griffecli-2.3.1}/src/griffecli/__init__.py +0 -0
- {griffecli-2.2.0 → griffecli-2.3.1}/src/griffecli/__main__.py +0 -0
- {griffecli-2.2.0 → griffecli-2.3.1}/src/griffecli/_internal/__init__.py +0 -0
- {griffecli-2.2.0 → griffecli-2.3.1}/src/griffecli/py.typed +0 -0
- {griffecli-2.2.0 → griffecli-2.3.1}/tests/__init__.py +0 -0
|
@@ -5,6 +5,52 @@ 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.1](https://github.com/mkdocstrings/griffe/releases/tag/2.3.1) - 2026-10-06
|
|
9
|
+
|
|
10
|
+
<small>[Compare with 2.3.0](https://github.com/mkdocstrings/griffe/compare/2.3.0...2.3.1)</small>
|
|
11
|
+
|
|
12
|
+
### Build
|
|
13
|
+
|
|
14
|
+
- Drop support for Python 3.10 ([686993d](https://github.com/mkdocstrings/griffe/commit/686993d4970d9fabbbd33334f88f48e1daed0565) by Timothée Mazzucotelli).
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
|
|
18
|
+
- Exit gracefully when checking API and no tags are found ([7c898a9](https://github.com/mkdocstrings/griffe/commit/7c898a9685c8ac29e1a4fd7767e85bf830b75a58) by Timothée Mazzucotelli).
|
|
19
|
+
|
|
20
|
+
## [2.3.0](https://github.com/mkdocstrings/griffe/releases/tag/2.3.0) - 2026-09-04
|
|
21
|
+
|
|
22
|
+
<small>[Compare with 2.2.0](https://github.com/mkdocstrings/griffe/compare/2.2.0...2.3.0)</small>
|
|
23
|
+
|
|
24
|
+
### Features
|
|
25
|
+
|
|
26
|
+
- 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)
|
|
27
|
+
|
|
28
|
+
### Bug Fixes
|
|
29
|
+
|
|
30
|
+
- 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>
|
|
31
|
+
- 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)
|
|
32
|
+
- Disable all docstring warnings when passing `warnings=False` ([5cb0ae2](https://github.com/mkdocstrings/griffe/commit/5cb0ae2f00748288c4009c1d4b6ee19f6aca6b76) by Timothée Mazzucotelli).
|
|
33
|
+
|
|
34
|
+
### Performance Improvements
|
|
35
|
+
|
|
36
|
+
- Reuse computed parent in `is_imported` ([092ac31](https://github.com/mkdocstrings/griffe/commit/092ac3162e1477a4b62eb875365996998adbd77d) by Timothée Mazzucotelli).
|
|
37
|
+
- Only build debug messages at debug level ([8f05a4a](https://github.com/mkdocstrings/griffe/commit/8f05a4ae5587d685bea1b0c98294a047b56c8df0) by Timothée Mazzucotelli).
|
|
38
|
+
- Avoid creating new sets when handling labels ([06cd02e](https://github.com/mkdocstrings/griffe/commit/06cd02e63c240286d11450887cc01b0ef76d8908) by Timothée Mazzucotelli).
|
|
39
|
+
- Maintain map of AST node type to visitor function ([e21851e](https://github.com/mkdocstrings/griffe/commit/e21851e732782823006223a7f5f8111b4200a257) by Timothée Mazzucotelli).
|
|
40
|
+
- Avoid cyclic refs in ASTs to allow garbage-collecting them ([b968de0](https://github.com/mkdocstrings/griffe/commit/b968de091afc1a4fd241f457538433ce3ada7520) by Timothée Mazzucotelli).
|
|
41
|
+
- Cache per-module path-related properties during serialization ([8bd6cc4](https://github.com/mkdocstrings/griffe/commit/8bd6cc4b34e96fc8235271cfa93a1a6a77091707) by Timothée Mazzucotelli).
|
|
42
|
+
- Do not fire load events when no extension has hooked them ([0e2ae7c](https://github.com/mkdocstrings/griffe/commit/0e2ae7c8cd1563d6dcca7a6c37fb8f2ec072cb24) by Timothée Mazzucotelli).
|
|
43
|
+
- Compute costly message lazily in alias resolution errors ([1e391b8](https://github.com/mkdocstrings/griffe/commit/1e391b8239747bb62908819e55468a961ffbaa99) by Timothée Mazzucotelli).
|
|
44
|
+
- Avoid iterating many times over function parameters when merging stubs ([03cae74](https://github.com/mkdocstrings/griffe/commit/03cae743e02c56af7375ffbfa70d6acf02e5491d) by Timothée Mazzucotelli).
|
|
45
|
+
- Avoid iterating many times over function parameters when diff'ing ([d3cf2c4](https://github.com/mkdocstrings/griffe/commit/d3cf2c41bb5f734e57b612b42d178e87af605ae8) by Timothée Mazzucotelli).
|
|
46
|
+
- Improve efficiency of AST parameter extraction ([1e37cd4](https://github.com/mkdocstrings/griffe/commit/1e37cd488d6adf55065b3ce4e7932faf1ff7d186) by Timothée Mazzucotelli).
|
|
47
|
+
- Cache serializable expression fields ([f9e48c1](https://github.com/mkdocstrings/griffe/commit/f9e48c16ebaeb719d5768cb921637aebe377a639) by Timothée Mazzucotelli).
|
|
48
|
+
- Use maps to make JSON encoder faster ([b7de96f](https://github.com/mkdocstrings/griffe/commit/b7de96fb516218ae3bf6a8e6d014a223df67f4a3) by Timothée Mazzucotelli).
|
|
49
|
+
- Avoid recomputing inherited members when diff'ing ([a29e028](https://github.com/mkdocstrings/griffe/commit/a29e028ff034752ff747dda17f3f875f22c2a192) by Timothée Mazzucotelli).
|
|
50
|
+
- Make Google, Numpy and Sphinx docstring parsers faster ([7f39373](https://github.com/mkdocstrings/griffe/commit/7f39373f8da779fb104dd2b6c11a02d95da628c4) by Timothée Mazzucotelli).
|
|
51
|
+
- Pre-compile patterns for docstring style detection ([ad58ad5](https://github.com/mkdocstrings/griffe/commit/ad58ad5b86390a8a02311189315dd4f59e0300a4) by Timothée Mazzucotelli).
|
|
52
|
+
- LRU-cache parsing of type annotations in docstrings ([1671e59](https://github.com/mkdocstrings/griffe/commit/1671e59fb675e9b45338956ce8aa5f5e56692690) by Timothée Mazzucotelli).
|
|
53
|
+
|
|
8
54
|
## [2.2.0](https://github.com/mkdocstrings/griffe/releases/tag/2.2.0) - 2026-08-16
|
|
9
55
|
|
|
10
56
|
<small>[Compare with 2.1.0](https://github.com/mkdocstrings/griffe/compare/2.1.0...2.2.0)</small>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
ISC License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2021, Timothée Mazzucotelli
|
|
3
|
+
Copyright (c) 2021, Timothée Mazzucotelli and contributors
|
|
4
4
|
|
|
5
5
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
6
|
purpose with or without fee is hereby granted, provided that the above
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: griffecli
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.3.1
|
|
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
|
|
@@ -10,7 +10,6 @@ Classifier: Intended Audience :: Developers
|
|
|
10
10
|
Classifier: Programming Language :: Python
|
|
11
11
|
Classifier: Programming Language :: Python :: 3
|
|
12
12
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
14
13
|
Classifier: Programming Language :: Python :: 3.11
|
|
15
14
|
Classifier: Programming Language :: Python :: 3.12
|
|
16
15
|
Classifier: Programming Language :: Python :: 3.13
|
|
@@ -22,4 +21,4 @@ Classifier: Topic :: Utilities
|
|
|
22
21
|
Classifier: Typing :: Typed
|
|
23
22
|
Requires-Python: >=3.10
|
|
24
23
|
Requires-Dist: colorama>=0.4
|
|
25
|
-
Requires-Dist: griffelib==2.
|
|
24
|
+
Requires-Dist: griffelib==2.3.1
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Griffe
|
|
2
2
|
|
|
3
3
|
[](https://github.com/mkdocstrings/griffe/actions?query=workflow%3Aci)
|
|
4
|
-
[](https://mkdocstrings.github.io/griffe/)
|
|
5
5
|
[](https://pypi.org/project/griffe/)
|
|
6
6
|
[](https://app.gitter.im/#/room/#mkdocstrings_griffe:gitter.im)
|
|
7
7
|
[](https://app.radicle.at/nodes/seed.radicle.at/rad:z4M5XTPDD4Wh1sm8iPCenF85J3z8Z)
|
|
@@ -19,8 +19,6 @@ classifiers = [
|
|
|
19
19
|
"Programming Language :: Python",
|
|
20
20
|
"Programming Language :: Python :: 3",
|
|
21
21
|
"Programming Language :: Python :: 3 :: Only",
|
|
22
|
-
# YORE: EOL 3.10: Remove line.
|
|
23
|
-
"Programming Language :: Python :: 3.10",
|
|
24
22
|
# YORE: EOL 3.11: Remove line.
|
|
25
23
|
"Programming Language :: Python :: 3.11",
|
|
26
24
|
# YORE: EOL 3.12: Remove line.
|
|
@@ -34,7 +34,7 @@ import logging
|
|
|
34
34
|
import os
|
|
35
35
|
import re
|
|
36
36
|
import sys
|
|
37
|
-
from datetime import
|
|
37
|
+
from datetime import UTC, datetime
|
|
38
38
|
from pathlib import Path
|
|
39
39
|
from typing import IO, TYPE_CHECKING, Any
|
|
40
40
|
|
|
@@ -91,6 +91,7 @@ def _load_packages(
|
|
|
91
91
|
force_inspection: bool = False,
|
|
92
92
|
store_source: bool = True,
|
|
93
93
|
find_stubs_package: bool = False,
|
|
94
|
+
prefer_stubs_docs: bool = False,
|
|
94
95
|
) -> GriffeLoader:
|
|
95
96
|
from griffe._internal.loader import GriffeLoader # noqa: PLC0415
|
|
96
97
|
from griffe._internal.logger import logger # noqa: PLC0415
|
|
@@ -104,6 +105,7 @@ def _load_packages(
|
|
|
104
105
|
allow_inspection=allow_inspection,
|
|
105
106
|
force_inspection=force_inspection,
|
|
106
107
|
store_source=store_source,
|
|
108
|
+
prefer_stubs_docs=prefer_stubs_docs,
|
|
107
109
|
)
|
|
108
110
|
|
|
109
111
|
# Load each package.
|
|
@@ -192,6 +194,14 @@ def get_parser() -> argparse.ArgumentParser:
|
|
|
192
194
|
default=False,
|
|
193
195
|
help="Whether to look for stubs-only packages and merge them with concrete ones.",
|
|
194
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
|
+
)
|
|
195
205
|
loading_options.add_argument(
|
|
196
206
|
"-e",
|
|
197
207
|
"--extensions",
|
|
@@ -358,6 +368,7 @@ def dump(
|
|
|
358
368
|
resolve_external: bool | None = None,
|
|
359
369
|
search_paths: Sequence[str | Path] | None = None,
|
|
360
370
|
find_stubs_package: bool = False,
|
|
371
|
+
prefer_stubs_docs: bool = False,
|
|
361
372
|
append_sys_path: bool = False,
|
|
362
373
|
allow_inspection: bool = True,
|
|
363
374
|
force_inspection: bool = False,
|
|
@@ -380,6 +391,7 @@ def dump(
|
|
|
380
391
|
find_stubs_package: Whether to search for stubs-only packages.
|
|
381
392
|
If both the package and its stubs are found, they'll be merged together.
|
|
382
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.
|
|
383
395
|
append_sys_path: Whether to append the contents of `sys.path` to the search paths.
|
|
384
396
|
allow_inspection: Whether to allow inspecting modules when visiting them is not possible.
|
|
385
397
|
force_inspection: Whether to force using dynamic analysis when loading data.
|
|
@@ -422,11 +434,12 @@ def dump(
|
|
|
422
434
|
force_inspection=force_inspection,
|
|
423
435
|
store_source=False,
|
|
424
436
|
find_stubs_package=find_stubs_package,
|
|
437
|
+
prefer_stubs_docs=prefer_stubs_docs,
|
|
425
438
|
)
|
|
426
439
|
data_packages = loader.modules_collection.members
|
|
427
440
|
|
|
428
441
|
# Serialize and dump packages.
|
|
429
|
-
started = datetime.now(tz=
|
|
442
|
+
started = datetime.now(tz=UTC)
|
|
430
443
|
if per_package_output:
|
|
431
444
|
for package_name, data in data_packages.items():
|
|
432
445
|
serialized = data.as_json(indent=2, full=full, sort_keys=True)
|
|
@@ -434,7 +447,7 @@ def dump(
|
|
|
434
447
|
else:
|
|
435
448
|
serialized = json.dumps(data_packages, cls=JSONEncoder, indent=2, full=full, sort_keys=True)
|
|
436
449
|
_print_data(serialized, output)
|
|
437
|
-
elapsed = datetime.now(tz=
|
|
450
|
+
elapsed = datetime.now(tz=UTC) - started
|
|
438
451
|
|
|
439
452
|
if stats:
|
|
440
453
|
loader_stats = loader.stats()
|
|
@@ -454,6 +467,7 @@ def check(
|
|
|
454
467
|
search_paths: Sequence[str | Path] | None = None,
|
|
455
468
|
append_sys_path: bool = False,
|
|
456
469
|
find_stubs_package: bool = False,
|
|
470
|
+
prefer_stubs_docs: bool = False,
|
|
457
471
|
allow_inspection: bool = True,
|
|
458
472
|
force_inspection: bool = False,
|
|
459
473
|
verbose: bool = False,
|
|
@@ -470,6 +484,8 @@ def check(
|
|
|
470
484
|
extensions: The extensions to use.
|
|
471
485
|
search_paths: The paths to search into.
|
|
472
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.
|
|
473
489
|
allow_inspection: Whether to allow inspecting modules when visiting them is not possible.
|
|
474
490
|
force_inspection: Whether to force using dynamic analysis when loading data.
|
|
475
491
|
verbose: Use a verbose output.
|
|
@@ -509,6 +525,7 @@ def check(
|
|
|
509
525
|
allow_inspection=allow_inspection,
|
|
510
526
|
force_inspection=force_inspection,
|
|
511
527
|
find_stubs_package=find_stubs_package,
|
|
528
|
+
prefer_stubs_docs=prefer_stubs_docs,
|
|
512
529
|
resolve_aliases=True,
|
|
513
530
|
resolve_external=None,
|
|
514
531
|
)
|
|
@@ -530,6 +547,7 @@ def check(
|
|
|
530
547
|
allow_inspection=allow_inspection,
|
|
531
548
|
force_inspection=force_inspection,
|
|
532
549
|
find_stubs_package=find_stubs_package,
|
|
550
|
+
prefer_stubs_docs=prefer_stubs_docs,
|
|
533
551
|
resolve_aliases=True,
|
|
534
552
|
resolve_external=None,
|
|
535
553
|
)
|
|
@@ -543,6 +561,10 @@ def check(
|
|
|
543
561
|
print(f"griffe: error: {error}", file=sys.stderr)
|
|
544
562
|
return 2
|
|
545
563
|
|
|
564
|
+
if not against:
|
|
565
|
+
print("griffe: info: 'against' ref not specified and no tags found", file=sys.stderr)
|
|
566
|
+
return 0
|
|
567
|
+
|
|
546
568
|
# Load old and new version of the package.
|
|
547
569
|
old_package = load_git(
|
|
548
570
|
against_path,
|
|
@@ -553,6 +575,7 @@ def check(
|
|
|
553
575
|
allow_inspection=allow_inspection,
|
|
554
576
|
force_inspection=force_inspection,
|
|
555
577
|
find_stubs_package=find_stubs_package,
|
|
578
|
+
prefer_stubs_docs=prefer_stubs_docs,
|
|
556
579
|
resolve_aliases=True,
|
|
557
580
|
resolve_external=None,
|
|
558
581
|
)
|
|
@@ -567,6 +590,7 @@ def check(
|
|
|
567
590
|
allow_inspection=allow_inspection,
|
|
568
591
|
force_inspection=force_inspection,
|
|
569
592
|
find_stubs_package=find_stubs_package,
|
|
593
|
+
prefer_stubs_docs=prefer_stubs_docs,
|
|
570
594
|
resolve_aliases=True,
|
|
571
595
|
resolve_external=None,
|
|
572
596
|
)
|
|
@@ -579,6 +603,7 @@ def check(
|
|
|
579
603
|
allow_inspection=allow_inspection,
|
|
580
604
|
force_inspection=force_inspection,
|
|
581
605
|
find_stubs_package=find_stubs_package,
|
|
606
|
+
prefer_stubs_docs=prefer_stubs_docs,
|
|
582
607
|
resolve_aliases=True,
|
|
583
608
|
resolve_external=None,
|
|
584
609
|
)
|
|
@@ -18,13 +18,18 @@
|
|
|
18
18
|
|
|
19
19
|
from __future__ import annotations
|
|
20
20
|
|
|
21
|
+
import json
|
|
21
22
|
import sys
|
|
23
|
+
from typing import TYPE_CHECKING
|
|
22
24
|
|
|
23
25
|
import pytest
|
|
24
26
|
|
|
25
27
|
from griffe._internal import debug
|
|
26
28
|
from griffecli._internal import cli
|
|
27
29
|
|
|
30
|
+
if TYPE_CHECKING:
|
|
31
|
+
from pathlib import Path
|
|
32
|
+
|
|
28
33
|
|
|
29
34
|
def test_main() -> None:
|
|
30
35
|
"""Basic CLI test."""
|
|
@@ -34,6 +39,26 @@ def test_main() -> None:
|
|
|
34
39
|
assert cli.main(["dump", "griffe", "-s", "src", "-o/dev/null"]) == 0
|
|
35
40
|
|
|
36
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
|
+
|
|
37
62
|
def test_show_help(capsys: pytest.CaptureFixture) -> None:
|
|
38
63
|
"""Show help.
|
|
39
64
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|