Fix autodoc: Show detailed warning when type_comment is mismatched (refs: #7807)

This commit is contained in:
Takeshi KOMIYA 2020-06-13 23:53:30 +09:00
parent 46f79c55e1
commit b3affa6949
2 changed files with 6 additions and 0 deletions

View File

@ -13,6 +13,9 @@ Deprecated
Features added Features added
-------------- --------------
* #7807: autodoc: Show detailed warning when type_comment is mismatched with its
signature
Bugs fixed Bugs fixed
---------- ----------

View File

@ -128,6 +128,9 @@ def update_annotations_using_type_comments(app: Sphinx, obj: Any, bound_method:
if 'return' not in obj.__annotations__: if 'return' not in obj.__annotations__:
obj.__annotations__['return'] = type_sig.return_annotation 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() except NotImplementedError as exc: # failed to ast.unparse()
logger.warning(__("Failed to parse type_comment for %r: %s"), obj, exc) logger.warning(__("Failed to parse type_comment for %r: %s"), obj, exc)