Skip to content

Commit 1539888

Browse files
committed
Autosummary don't filter attributes on qualname
For inherited attributes qualname will not match the name of the actual obj that the attribute belongs to
1 parent e867201 commit 1539888

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

sphinx/ext/autosummary/__init__.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,10 @@ def import_ivar_by_name(name: str, prefixes: List[str] = [None],
716716
analyzer = ModuleAnalyzer.for_module(getattr(obj, '__module__', modname))
717717
analyzer.analyze()
718718
# check for presence in `annotations` to include dataclass attributes
719-
if (qualname, attr) in analyzer.attr_docs or (qualname, attr) in analyzer.annotations:
719+
attrs_found = {name_attr[1] for name_attr in analyzer.attr_docs} | {
720+
name_attr[1] for name_attr in analyzer.annotations
721+
}
722+
if attr in attrs_found:
720723
return real_name + "." + attr, INSTANCEATTR, obj, modname
721724
except (ImportError, ValueError, PycodeError) as exc:
722725
raise ImportError from exc

0 commit comments

Comments
 (0)