Skip to content

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.

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.

Each finding covers the complete initializer and records its executable statement count. The Boolean value is true only when that count is 0.

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.

Bad

An `__init__.py` containing only `\"\"\"Package docs.\"\"\"` returns `true`.
Good

An initializer containing from .client import Client returns false.