Mark a subclass method with typing.override
Answer: override marks a method in a subclass that is intended to override a method or attribute in a superclass. PEP 698 adds it to the Python type system so type checkers can catch bugs when a base class changes methods inherited by derived classes.
What type checkers do
Type checkers should emit an error if the decorated method does not, in fact, override anything. That helps prevent bugs when a base class is refactored.
When to write it
The decorator is for static typing. Type checkers should emit an error if the method does not, in fact, override anything.
| @override | type checker | |---|---| | override | Decorator on a subclass method or attribute | | superclass | The method or attribute being overridden | | emit an error | When the decorated method does not override anything | | refactor | A base class change can break derived classes |
See also
Claims
- id: C1 claim: PEP 698 adds an @override decorator so type checkers can catch broken inherited methods. source: S1 evidence: "adding an @override decorator to the Python type system"
- id: C2 claim: That helps when a base class changes methods that derived classes inherit. source: S1 evidence: "when a base class changes methods that are inherited by derived classes"
- id: C3 claim: Type checkers should emit an error if @override does not override anything. source: S2 evidence: "Type checkers should emit an error if a method decorated with @override"
Sources
- [S1] PEP 698 – Override Decorator for Static Typing. Python PEPs. https://peps.python.org/pep-0698/ . License: Public-Domain. Accessed 2026-11-19.
- [S2] typing — Support for type hints. Python docs. https://docs.python.org/3/library/typing.html . License: PSF-2.0. Accessed 2026-11-19.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Python PEPs, PEP 698 – Override Decorator for Static Typing; Python docs, typing — Support for type hints. Public-Domain; PSF-2.0. Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Python PEPs, PEP 698 – Override Decorator for Static Typing; Python docs, typing — Support for type hints. Public-Domain; PSF-2.0.
Cite this
iinventedlight. 2026. "Mark a subclass method with typing.override." iinventedlight Library, iil:note:x5cac5fq, version of 2026-11-19. https://iinventedlight.com/library/notes/python-typing-override/. License: CC-BY-4.0.
@misc{iil_note_x5cac5fq,
author = {{iinventedlight}},
title = {{Mark a subclass method with typing.override}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-19},
url = {https://iinventedlight.com/library/notes/python-typing-override/},
note = {Permanent ID iil:note:x5cac5fq. 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).
Extra files beside this note
These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.
- python-typing-override.table.json (table; CC-BY-4.0)
- python-typing-override.schema.json (schema; CC-BY-4.0)
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/python-typing-override.md.