PY-MODU0001 · non_init_reexport_module
Find barrel modules that define no behavior beyond re-exporting imports.
This is a deterministic rule for python. Read its implementation.
Definition
Section titled “Definition”Report an ordinary Python file when its complete executable body contains only imports and an
__all__ assignment. Package __init__.py files are the explicit export boundary. A module
named models.py, types.py, or any other name must define the concept its name promises
instead of forwarding unrelated definitions.
Evidence
Section titled “Evidence”The finding cites every import line and the full barrel module range. Modules with a class, function, constant, registration call, or other executable statement are not classified as pure re-export barrels.
Exceptions
Section titled “Exceptions”Package initializers are always excluded. A compatibility facade may disable the rule while a migration is active, though compatibility-only modules should not remain by default in a new project.
Examples
Section titled “Examples”Bad
`models.py` imports `User`, `Finding`, and `Status` from other modules and lists them in`__all__` without defining a model.
Goodmodels/__init__.py exports shared model classes defined one per sibling file. Internal code
may also import the defining modules directly when no public package surface is needed.
References
Section titled “References”- Cites “The Python Language Reference”, packages and package initialization. Open reference
- Cites “The Python Language Reference”,
__all__reference. Open reference - Cites “A Philosophy of Software Design”, chapters 4 and 7