-
-
Couldn't load subscription status.
- Fork 33.2k
Open
Labels
3.14bugs and security fixesbugs and security fixes3.15new features, bugs and security fixesnew features, bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-typingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
On Python 3.14, it seems that pipe unions with typing.Union and str objects raise a TypeError. This is a regression from Python 3.13 behaviour, where Union could be or'd with a str to create a Union with a ForwardRef.
Python 3.13 behaviour
>>> from typing import Union
>>> Union[int, str] | 'tuple'
typing.Union[int, str, ForwardRef('tuple')]Python 3.14 behaviour
>>> from typing import Union
>>> Union[int, str] | 'tuple'
Traceback (most recent call last):
File "<python-input-1>", line 1, in <module>
Union[int, str] | 'tuple'
~~~~~~~~~~~~~~~~^~~~~~~~~
TypeError: unsupported operand type(s) for |: 'typing.Union' and 'str'Version information
>>> sys.version_info
sys.version_info(major=3, minor=14, micro=0, releaselevel='final', serial=0)CPython versions tested on:
3.14
Operating systems tested on:
Linux
Linked PRs
Metadata
Metadata
Assignees
Labels
3.14bugs and security fixesbugs and security fixes3.15new features, bugs and security fixesnew features, bugs and security fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-typingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error