PEP 604

E901490

PEP 604 is a Python Enhancement Proposal that introduced the modern, concise syntax for expressing type unions (using the `|` operator) in Python’s type hints.

Try in SPARQL Jump to: Surface forms Statements Referenced by

All labels observed (1)

Label Occurrences
PEP 604 canonical 2

Statements (36)

Predicate Object
instanceOf Python Enhancement Proposal
acceptedBy Python core developers NERFINISHED
affects Python type hinting system
appliesTo typing.Optional via X | None
author Jelle Zijlstra NERFINISHED
Pradeep Kumar Srinivasan NERFINISHED
Łukasz Langa NERFINISHED
category Typing
clarifies how unions are represented at runtime
interaction of | with existing typing constructs
createdForVersion Python 3.10 NERFINISHED
defines behavior of | operator on types at runtime
semantics of X | Y for typing
discusses backwards compatibility of union syntax
documentedAt https://peps.python.org/pep-0604/
governs syntax of union types in standard library type hints
hasNumber 604
hasTitle Allow writing union types as X | Y
influences type checkers such as Pyre
type checkers such as mypy
type checkers such as pyright
introducedIn Python 3.10 NERFINISHED
language Python NERFINISHED
motivation make type hints more readable
reduce verbosity of typing.Union
proposesFeature modern concise syntax for type unions
using | operator for type unions in type hints
recommends preferring X | Y over typing.Union[X, Y] in new code
relatedTo PEP 563 NERFINISHED
PEP 585 NERFINISHED
PEP 649 NERFINISHED
replacesSyntax typing.Union[X, Y] with X | Y
scope static type checking
standardizes use of | for unions across typing ecosystem
status Final
usesOperator bitwise or operator |

Referenced by (2)

Full triples — surface form annotated when it differs from this entity's canonical label.