summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2020-09-12 21:15:20 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2020-10-03 22:35:35 +0900
commita555e3db8a2e38dc7f79c3dd8ac6cd406f70c9e1 (patch)
tree030be6c71dabff2640680e5da64d4f9f6573cce7
parent88b81a06eb635a1596617f8971fa97a84c069e93 (diff)
downloadsphinx-git-a555e3db8a2e38dc7f79c3dd8ac6cd406f70c9e1.tar.gz
Fix #8200: autodoc: type aliases break type formatting
The annotation option is shared between auto directives unexpectedly. It causes supression of type annotations for objects after GenericAlias definition.
-rw-r--r--CHANGES1
-rw-r--r--sphinx/ext/autodoc/__init__.py6
2 files changed, 5 insertions, 2 deletions
diff --git a/CHANGES b/CHANGES
index df70ab46e..5637f66d6 100644
--- a/CHANGES
+++ b/CHANGES
@@ -34,6 +34,7 @@ Bugs fixed
by string not ending with blank lines
* #8142: autodoc: Wrong constructor signature for the class derived from
typing.Generic
+* #8200: autodoc: type aliases break type formatting of autoattribute
* #8192: napoleon: description is disappeared when it contains inline literals
* #8142: napoleon: Potential of regex denial of service in google style docs
* #8169: LaTeX: pxjahyper loaded even when latex_engine is not platex
diff --git a/sphinx/ext/autodoc/__init__.py b/sphinx/ext/autodoc/__init__.py
index d7c5d2242..83c44c8df 100644
--- a/sphinx/ext/autodoc/__init__.py
+++ b/sphinx/ext/autodoc/__init__.py
@@ -1731,7 +1731,8 @@ class GenericAliasDocumenter(DataDocumenter):
return inspect.isgenericalias(member)
def add_directive_header(self, sig: str) -> None:
- self.options.annotation = SUPPRESS # type: ignore
+ self.options = Options(self.options)
+ self.options['annotation'] = SUPPRESS
super().add_directive_header(sig)
def add_content(self, more_content: Any, no_docstring: bool = False) -> None:
@@ -1755,7 +1756,8 @@ class TypeVarDocumenter(DataDocumenter):
return isinstance(member, TypeVar) and isattr # type: ignore
def add_directive_header(self, sig: str) -> None:
- self.options.annotation = SUPPRESS # type: ignore
+ self.options = Options(self.options)
+ self.options['annotation'] = SUPPRESS
super().add_directive_header(sig)
def get_doc(self, encoding: str = None, ignore: int = None) -> List[List[str]]: