diff --git a/src/griffe/mixins.py b/src/griffe/mixins.py index f3fe7913..4c07f771 100644 --- a/src/griffe/mixins.py +++ b/src/griffe/mixins.py @@ -329,6 +329,11 @@ def is_class_private(self) -> bool: """Whether this object/alias is class-private (starts with `__` and is a class member).""" return self.parent and self.parent.is_class and self.name.startswith("__") and not self.name.endswith("__") # type: ignore[attr-defined] + @property + def is_imported(self) -> bool: + """Whether this object/alias was imported from another module.""" + return self.parent and self.name in self.parent.imports # type: ignore[attr-defined] + @property def is_exported(self) -> bool: """Whether this object/alias is exported (listed in `__all__`).""" @@ -377,7 +382,7 @@ def is_wildcard_exposed(self) -> bool: return self.name in self.parent.exports # type: ignore[attr-defined] if self.name.startswith("_"): # type: ignore[attr-defined] return False - return self.is_alias or not self.is_module or self.name in self.parent.imports # type: ignore[attr-defined] + return self.is_alias or not self.is_module or self.is_imported # type: ignore[attr-defined] @property def is_public(self) -> bool: