← All notes

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

Sources

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

Permanent ID: iil:note:zjwyy296

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.},
}

Markdown

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.