PY-MODU0004 · explicit_all_only_in_initializer
Keep explicit package export lists inside package initializers.
This is a deterministic rule for python. Read its implementation.
Definition
Section titled “Definition”Report an ordinary Python module that assigns or extends __all__. A defining module already
publishes its public names through ordinary Python visibility, while a package initializer is
the one place that combines sibling definitions into a package surface.
Evidence
Section titled “Evidence”Each finding covers the complete module that declares __all__. The Boolean value is true
only when that declaration appears outside __init__.py.
Exceptions
Section titled “Exceptions”Package initializers may build __all__ through assignments, annotations, or augmented
assignments. A generated compatibility facade can exclude its exact path while the migration
that requires it remains active.
Examples
Section titled “Examples”Bad
`service.py` containing `__all__ = [\"Client\"]` returns `true`.
GoodThe same declaration in service/__init__.py returns false.
References
Section titled “References”- Cites “The Python Language Reference”, the import statement. Open reference
- Cites “PEP 8, Style Guide for Python Code”, Public and Internal Interfaces. Open reference