Skip to content

Commit

Permalink
fix: Short-circuit __all__ convention when checking if a module is …
Browse files Browse the repository at this point in the history
…public
  • Loading branch information
pawamoy committed Jul 14, 2024
1 parent c2bbc10 commit 5abf4e3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/_griffe/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 5abf4e3

Please sign in to comment.