Skip to content

Commit

Permalink
feat: Add is_imported property to objects/aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
pawamoy committed Jun 18, 2024
1 parent 491b6c4 commit de926cc
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/griffe/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__`)."""
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit de926cc

Please # to comment.