From 5abf4e3343410dbd41760415cff7c5f9e8c2b6b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Mazzucotelli?= Date: Wed, 10 Jul 2024 21:14:46 +0200 Subject: [PATCH] fix: Short-circuit `__all__` convention when checking if a module is public --- src/_griffe/mixins.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/_griffe/mixins.py b/src/_griffe/mixins.py index d932b914..ec78e914 100644 --- a/src/_griffe/mixins.py +++ b/src/_griffe/mixins.py @@ -452,6 +452,12 @@ def is_public(self) -> bool: # YORE: Bump 1.0.0: Replace line with `return self.public`. return _True if self.public else _False # type: ignore[return-value,attr-defined] + # If the object is a module and its name does not start with an underscore, it is public. + # Modules are not subject to the `__all__` convention, only the underscore prefix one. + if not self.is_alias and self.is_module and not self.name.startswith("_"): # type: ignore[attr-defined] + # YORE: Bump 1.0.0: Replace line with `return True`. + return _True # type: ignore[return-value] + # If the object is defined at the module-level and is listed in `__all__`, it is public. # If the parent module defines `__all__` but does not list the object, it is private. if self.parent and self.parent.is_module and bool(self.parent.exports): # type: ignore[attr-defined]