Skip to content

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.

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.

Findings cite implementations, calls, runtime checks, shared methods, and extension needs.

Framework contracts and public plugin APIs may need stronger runtime structure.

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.

  • Cites “Fluent Python”, Interfaces, Protocols, and ABCs
  • Cites “PEP 544, Protocols”
  • Cites “The Python Standard Library”, abc