Skip to content

PY-MODU0005 · unused_explicit_export

Count explicit package exports no repository consumer uses.

This is a deterministic rule for python. Read its implementation.

Read every name a Python module explicitly publishes through __all__ and count references that enter through that public module and name. Report an export when no other source file uses the route. Direct use of the defining module does not prove the extra public route useful.

Each finding names the public name, the declaration it resolves to, and the exporting module. The value is the number of explicit exports with zero repository consumers.

A library may intentionally publish an API only external clients use. Exclude that exact public boundary when the release contract proves the consumer exists outside the scanned repository. Dynamic string lookup is not counted because it does not state the import route statically.

Bad

`pkg.__all__` lists `Engine`, but no repository file imports or accesses `pkg.Engine`.
Good

from pkg import Client consumes the explicit Client export and returns zero for that name.

  • Cites “The Python Language Reference”, the import statement and __all__
  • Cites “Refactoring”, Remove Dead Code