← All notes

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

Sources

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

Permanent ID: iil:note:x5cac5fq

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

Markdown

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.

All artifact files (JSON index)

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.