Skip to content

PY-NAMI0002 · attribute_visibility

Count public methods proven to be private implementation details.

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

Report a public Python method when every resolved reference comes from inside its declaring class. The owner must already be non-public, at least one owner reference must exist, no reference may come from another owner, and no unresolved reference with the same member name may remain anywhere in the repository.

Each finding records owner, non-owner, and unresolved same-name usage counts. These three counts make the conclusion deterministic instead of asking a model to infer intent from a spelling. The value is the number of public methods whose complete repository usage proves that they are implementation details of a non-public owner.

Decorated methods and every class participating in inheritance are excluded because framework and subclass contracts may call members without ordinary graph edges. A public owner is also excluded because downstream users outside the repository may depend on its methods. An unused method is left to dead-code analysis rather than renamed.

_Parser.parse called only by _Parser.run is reported and should become _parse. Parser.parse is not reported because Parser may be a public API. _Parser.parse is also left alone when client.parse() remains unresolved or a derived class participates.

  • Cites “PEP 8, Style Guide for Python Code”, public and internal interfaces. Open reference
  • Cites “The Python Tutorial”, private variables and class-local references. Open reference