From 1e19e7b2c3f2bb10c822c7d8b63b04a76024b4f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Mazzucotelli?= Date: Sat, 26 Aug 2023 10:46:44 +0200 Subject: [PATCH] fix: Preserve inherited attribute on alias inherited members Issue mkdocstrings/python#102: https://github.com/mkdocstrings/python/issues/102 --- src/griffe/dataclasses.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/griffe/dataclasses.py b/src/griffe/dataclasses.py index c98797dd..c4cc3657 100644 --- a/src/griffe/dataclasses.py +++ b/src/griffe/dataclasses.py @@ -886,7 +886,10 @@ def docstring(self, docstring: Docstring | None) -> None: @cached_property def members(self) -> dict[str, Object | Alias]: # noqa: D102 final_target = self.final_target - return {name: Alias(name, target=member, parent=self) for name, member in final_target.members.items()} + return { + name: Alias(name, target=member, parent=self, inherited=False) + for name, member in final_target.members.items() + } @property def labels(self) -> set[str]: # noqa: D102 @@ -911,7 +914,8 @@ def member_is_exported(self, member: Object | Alias, *, explicitely: bool = True def inherited_members(self) -> dict[str, Alias]: # noqa: D102 final_target = self.final_target return { - name: Alias(name, target=member, parent=self) for name, member in final_target.inherited_members.items() + name: Alias(name, target=member, parent=self, inherited=True) + for name, member in final_target.inherited_members.items() } def is_kind(self, kind: str | Kind | set[str | Kind]) -> bool: # noqa: D102