From 491b6c4da086a68e8e1eee13f2d4b7840390b6b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Mazzucotelli?= Date: Tue, 18 Jun 2024 12:51:50 +0200 Subject: [PATCH] feat: Add `is_class_private` property to objects/aliases --- src/griffe/mixins.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/griffe/mixins.py b/src/griffe/mixins.py index 1853a2d6..f3fe7913 100644 --- a/src/griffe/mixins.py +++ b/src/griffe/mixins.py @@ -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__`)."""