Skip to content

Commit

Permalink
feat: Add is_class_private 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 ae7c7e7 commit 491b6c4
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/griffe/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,11 @@ def is_special(self) -> bool:
"""Whether this object/alias is special ("dunder" attribute/method, starts and end with `__`)."""
return self.name.startswith("__") and self.name.endswith("__") # type: ignore[attr-defined]

@property
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_exported(self) -> bool:
"""Whether this object/alias is exported (listed in `__all__`)."""
Expand Down

0 comments on commit 491b6c4

Please # to comment.