PEP 544
E939794
PEP 544 is a Python Enhancement Proposal that introduces structural subtyping via typing.Protocol, enabling static type checkers to support interface-like behavior based on object capabilities rather than inheritance.
Statements (47)
| Predicate | Object |
|---|---|
| instanceOf | Python Enhancement Proposal ⓘ |
| affectsModule | typing ⓘ |
| allows |
runtime isinstance checks for some protocols
ⓘ
subtyping based on method signatures ⓘ subtyping without explicit inheritance ⓘ |
| availableVia | typing_extensions in older Python versions ⓘ |
| buildsOn |
PEP 484
NERFINISHED
ⓘ
PEP 526 NERFINISHED ⓘ |
| category | Typing ⓘ |
| clarifies | relationship between ABCs and protocols ⓘ |
| compatibleWith |
Pyright
NERFINISHED
ⓘ
mypy NERFINISHED ⓘ other PEP 484-style type checkers ⓘ |
| contrastsWith | nominal subtyping ⓘ |
| createdForVersion | Python 3 NERFINISHED ⓘ |
| defines | protocols for static typing ⓘ |
| definesSyntaxElement |
Protocol base class
ⓘ
runtime_checkable decorator ⓘ |
| definesTerm |
protocol
ⓘ
runtime protocol ⓘ static protocol ⓘ |
| enables |
interface-like behavior based on object capabilities
ⓘ
static duck typing ⓘ |
| focusesOn | static type checking ⓘ |
| hasNumber | 544 ⓘ |
| hasTitle | Protocols: Structural subtyping (static duck typing) NERFINISHED ⓘ |
| influences | design of typing_extensions.Protocol ⓘ |
| introducesConcept |
structural subtyping
ⓘ
typing.Protocol NERFINISHED ⓘ |
| language | Python NERFINISHED ⓘ |
| mainFeature |
callback protocols
ⓘ
generic protocols ⓘ protocol inheritance ⓘ runtime-checkable protocols ⓘ subtyping based on object capabilities ⓘ |
| motivation |
better support for large code bases using duck typing
ⓘ
provide standard way to define static protocols ⓘ |
| primaryMechanism | typing.Protocol base class ⓘ |
| recommends | using protocols instead of ABCs for some use cases ⓘ |
| status | Final ⓘ |
| subtypingStyle | structural ⓘ |
| supports |
interface-based programming style
ⓘ
static type checkers ⓘ |
| type | Standards Track ⓘ |
| useCase |
defining interfaces for libraries
ⓘ
gradual typing of existing code ⓘ static checking of duck-typed code ⓘ |
Referenced by (1)
Full triples — surface form annotated when it differs from this entity's canonical label.