Skip to content

Commit

Permalink
Merge pull request #8274 from tk0miya/8200_typealias_break_type_annot…
Browse files Browse the repository at this point in the history
…ation

Fix #8200: autodoc: type aliases break type formatting
  • Loading branch information
tk0miya committed Oct 4, 2020
2 parents 38bb377 + d8cdad9 commit a8abb99
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES
Expand Up @@ -41,6 +41,7 @@ Bugs fixed
typing.Generic
* #8157: autodoc: TypeError is raised when annotation has invalid __args__
* #7964: autodoc: Tuple in default value is wrongly rendered
* #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
Expand Down
6 changes: 4 additions & 2 deletions sphinx/ext/autodoc/__init__.py
Expand Up @@ -1736,7 +1736,8 @@ def can_document_member(cls, member: Any, membername: str, isattr: bool, parent:
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:
Expand All @@ -1760,7 +1761,8 @@ def can_document_member(cls, member: Any, membername: str, isattr: bool, parent:
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]]:
Expand Down

0 comments on commit a8abb99

Please sign in to comment.