From b3affa6949d3858312a28ff75a8161bfaf5db8ee Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sat, 13 Jun 2020 23:53:30 +0900 Subject: [PATCH] Fix autodoc: Show detailed warning when type_comment is mismatched (refs: #7807) --- CHANGES | 3 +++ sphinx/ext/autodoc/type_comment.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/CHANGES b/CHANGES index 4198395c6..5f8d82d4a 100644 --- a/CHANGES +++ b/CHANGES @@ -13,6 +13,9 @@ Deprecated Features added -------------- +* #7807: autodoc: Show detailed warning when type_comment is mismatched with its + signature + Bugs fixed ---------- diff --git a/sphinx/ext/autodoc/type_comment.py b/sphinx/ext/autodoc/type_comment.py index e6a77f24d..7f11e3d12 100644 --- a/sphinx/ext/autodoc/type_comment.py +++ b/sphinx/ext/autodoc/type_comment.py @@ -128,6 +128,9 @@ def update_annotations_using_type_comments(app: Sphinx, obj: Any, bound_method: if 'return' not in obj.__annotations__: obj.__annotations__['return'] = type_sig.return_annotation + except KeyError as exc: + logger.warning(__("Failed to update signature for %r: parameter not found: %s"), + obj, exc) except NotImplementedError as exc: # failed to ast.unparse() logger.warning(__("Failed to parse type_comment for %r: %s"), obj, exc)