PY-INTE0002 · single_implementation_abstract_base
Count abstract bases that support only one repository implementation.
This is a deterministic rule for python. Read its implementation.
Definition
Section titled “Definition”Build the repository inheritance graph and report a top-level Python class that explicitly
derives from ABC or ABCMeta, or declares an abstract member, when exactly one descendant
implements it. An abstract base adds indirection to let implementations vary. With only one
implementation, the indirection has cost but no choice.
Evidence
Section titled “Evidence”Each finding names the abstract base, its one descendant, and the complete declaration range. The value is the number of single-implementation abstract bases in the file.
Exceptions
Section titled “Exceptions”Protocols are excluded because structural implementations need not inherit the protocol and a closed-world subclass graph cannot count them. An abstract base with two or more descendants has earned its variation point. A base with no descendants is owned by the separate unused declaration and abstraction reach rules.
Examples
Section titled “Examples”Bad
An abstract `FactProvider` with only `DependencyProvider` below it returns `1`.
GoodAn abstract Renderer implemented by JsonRenderer and TextRenderer returns 0.
References
Section titled “References”- Cites “The Python Standard Library”,
abc - Cites “A Philosophy of Software Design”, deep modules and useful abstractions