Skip to content

Commit 8b9a3ed

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 213c29b commit 8b9a3ed

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
@@ -715,7 +715,10 @@ def import_ivar_by_name(name: str, prefixes: List[str] = [None],
715715
analyzer = ModuleAnalyzer.for_module(getattr(obj, '__module__', modname))
716716
analyzer.analyze()
717717
# check for presence in `annotations` to include dataclass attributes
718-
if (qualname, attr) in analyzer.attr_docs or (qualname, attr) in analyzer.annotations:
718+
attrs_found = {name_attr[1] for name_attr in analyzer.attr_docs} | {
719+
name_attr[1] for name_attr in analyzer.annotations
720+
}
721+
if attr in attrs_found:
719722
return real_name + "." + attr, INSTANCEATTR, obj, modname
720723
except (ImportError, ValueError, PycodeError) as exc:
721724
raise ImportError from exc

0 commit comments

Comments
 (0)