Skip to content

Python · correctness

no-duplicate-dunder-all-entry

python:no-duplicate-dunder-all-entry

static package `__all__` declarations should list each exported name once

Code
SARJ098
Default
error
Fix
none
Languages
python

Why

Duplicate exports add noise to a package's public contract and commonly reveal copy-paste mistakes in generated or maintained facade lists.

Fix

Remove each later duplicate while preserving the first declaration of the exported name.

Before / after

Executed by this rule’s unit tests.

Before

Duplicate name in a package export list

diagnostics/__init__.py · focus
__all__ = ["Diagnostic", "AnalysisReport", "Diagnostic"]

After

Unique names in a package export list

diagnostics/__init__.py · focus
__all__ = ["Diagnostic", "AnalysisReport"]

Limits

  • Only one fully static list or tuple assigned to package-level `__all__` is analyzed.
  • Generated, dynamically extended, reassigned, and non-package declarations are excluded.