From 6225ffd238489aa72502bd3ce47c766d5948aefe Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Sat, 1 Aug 2020 19:45:12 +0900 Subject: [PATCH] Fix #8030: autodoc: An annotated instance variable is not documented Documenter.filter_members() have wrongly considered that an instance variable not having a docstring should be skipped when `:inherited-members:` option given. This fixes the behavior when the instance variable has annotated. Note: This doest not still detect well for not annotated instance variables. --- CHANGES | 2 ++ sphinx/ext/autodoc/__init__.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/CHANGES b/CHANGES index eadace6dc..552df6da0 100644 --- a/CHANGES +++ b/CHANGES @@ -56,6 +56,8 @@ Bugs fixed * #904: autodoc: An instance attribute cause a crash of autofunction directive * #1362: autodoc: ``private-members`` option does not work for class attributes * #7983: autodoc: Generator type annotation is wrongly rendered in py36 +* #8030: autodoc: An uninitialized annotated instance variable is not documented + when ``:inherited-members:`` option given * #7839: autosummary: cannot handle umlauts in function names * #7865: autosummary: Failed to extract summary line when abbreviations found * #7866: autosummary: Failed to extract correct summary line when docstring diff --git a/sphinx/ext/autodoc/__init__.py b/sphinx/ext/autodoc/__init__.py index 8c3509c3b..554997ff7 100644 --- a/sphinx/ext/autodoc/__init__.py +++ b/sphinx/ext/autodoc/__init__.py @@ -579,6 +579,8 @@ class Documenter: return True elif name in cls.__dict__: return False + elif name in self.get_attr(cls, '__annotations__', {}): + return False return False