PY-INTE1001 · python_interface_form
Recommend the smallest Python interface form that fits actual variation.
This is a contextual rule for python. Read its implementation.
Definition
Section titled “Definition”Compare implementations, callers, static typing, runtime checks, shared behavior, extension ownership, and function signatures before choosing a concrete type, protocol, ABC, callable, or implicit duck-typed contract. The criteria independently establish implementations, static contract need, runtime structure, a single call shape, and local dynamic use.
Evidence
Section titled “Evidence”Findings cite implementations, calls, runtime checks, shared methods, and extension needs.
Exceptions
Section titled “Exceptions”Framework contracts and public plugin APIs may need stronger runtime structure.
Examples
Section titled “Examples”Several unrelated senders sharing one send method is protocol. One injected transformation
passed as a function is callable. A hierarchy a registry loads at run time is abc, and a
single implementation nothing else stands in for is concrete.
References
Section titled “References”- Cites “Fluent Python”, Interfaces, Protocols, and ABCs
- Cites “PEP 544, Protocols”
- Cites “The Python Standard Library”, abc