Protocol describes structural subtyping for static duck typing
Answer: Protocol is the base class for protocol classes. Protocol classes are defined like class Proto(Protocol) with a meth method. Static type checkers that recognize structural subtyping (static duck-typing) are the main consumers of those classes.
The example defines class C with def meth(self) -> int. Then func(C()) passes a static type check.
PEP 544
PEP 484 specifies the semantics of nominal subtyping. This PEP specifies static and runtime semantics of protocol classes. Those protocol classes provide support for structural subtyping (static duck typing).
See also
Claims
- id: C1 claim: Protocol is the base class for protocol classes. source: S1 evidence: "Base class for protocol classes."
- id: C2 claim: Protocol classes are used with structural subtyping. source: S1 evidence: "structural subtyping (static duck-typing), for example:"
- id: C3 claim: PEP 544 specifies semantics of protocol classes. source: S2 evidence: "static and runtime semantics of protocol classes that will provide a support"
- id: C4 claim: The PEP targets structural subtyping, also called static duck typing. source: S2 evidence: "for structural subtyping (static duck typing)."
Sources
- [S1] typing.Protocol. Python docs. https://docs.python.org/3/library/typing.html . License: PSF-2.0. Accessed 2026-11-16.
- [S2] PEP 544 – Protocols: Structural subtyping (static duck typing). Python PEPs. https://peps.python.org/pep-0544/ . License: Public domain or CC0-1.0. Accessed 2026-11-16.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Python docs, typing.Protocol, PSF-2.0 (https://docs.python.org/3/license.html); Python PEPs, PEP 544 – Protocols: Structural subtyping (static duck typing), Public domain or CC0-1.0 (https://peps.python.org/pep-0544/ (Copyright section: public domain)). Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Python docs, typing.Protocol, PSF-2.0 (https://docs.python.org/3/license.html); Python PEPs, PEP 544 – Protocols: Structural subtyping (static duck typing), Public domain or CC0-1.0 (https://peps.python.org/pep-0544/ (Copyright section: public domain)).
Cite this
iinventedlight. 2026. "Protocol describes structural subtyping for static duck typing." iinventedlight Library, iil:note:zjwyy296, version of 2026-11-16. https://iinventedlight.com/library/notes/python-typing-protocol/. License: CC-BY-4.0.
@misc{iil_note_zjwyy296,
author = {{iinventedlight}},
title = {{Protocol describes structural subtyping for static duck typing}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-16},
url = {https://iinventedlight.com/library/notes/python-typing-protocol/},
note = {Permanent ID iil:note:zjwyy296. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/python-typing-protocol.md.