Hi everyone,
Building on Guido’s comments at the recent PyCon US Typing Summit regarding the evolution of type hints, I’d like to propose elevating structural typing to a first-class language feature by introducing protocol as a soft keyword. When PEP 484 was introduced, the guiding constraint was “no new syntax.” As a result, we had to bolt typing features onto existing runtime mechanics. For Protocols (PEP 544), that meant using class inheritance:
from typing import Protocol
class Drawable(Protocol):
def draw(self) -> None: ...
The motivation for changing this is not to reduce boilerplate. A single inherited class is not the end of the world. Instead, it is confusing, since classes and “interfaces” are fundamentally different concepts that many modern type systems distinguish clearly. A Protocol is fundamentally a structural contract, not an object-oriented base class. Using subclassing syntax to define an interface conceptually conflates static structural typing with runtime inheritance. By introducing a protocol soft keyword, we clearly separate the two concepts:
protocol Drawable:
def draw(self) -> None: ...
This follows the precedent set by the type soft keyword in Python 3.12 (PEP 695), which showed the value of elevating core typing constructs from module imports to native syntax. Before I draft a formal PEP, I would love to hear the community’s thoughts on the appetite for this, and any initial feedback from those familiar with the PEG parser’s soft keyword mechanics.
CC: @Jelle for hallway track conversations we had at PyCon