PY-MODU0002 · empty_package_initializer
Report a package initializer that states no executable package surface.
This is a deterministic rule for python. Read its implementation.
Definition
Section titled “Definition”Inspect each production Python __init__.py after parsing and report it when comments,
whitespace, and an optional module docstring are its only content. A package initializer should
state a public surface or be absent so the directory participates as a namespace package.
Evidence
Section titled “Evidence”Each finding covers the complete initializer and records its executable statement count. The
Boolean value is true only when that count is 0.
Exceptions
Section titled “Exceptions”An initializer containing imports, __all__, or a supported module customization hook is not
empty. Test packages are excluded because their package identity can be what makes relative
fixture and support imports work under the test runner.
Examples
Section titled “Examples”Bad
An `__init__.py` containing only `\"\"\"Package docs.\"\"\"` returns `true`.
GoodAn initializer containing from .client import Client returns false.
References
Section titled “References”- Cites “PEP 420, Implicit Namespace Packages”. Open reference
- Cites “The Python Tutorial”, packages. Open reference