We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 34f2390 commit 40d1d28Copy full SHA for 40d1d28
Doc/library/stdtypes.rst
@@ -5109,6 +5109,14 @@ enables cleaner type hinting syntax compared to :data:`typing.Union`.
5109
def square(number: int | float) -> int | float:
5110
return number ** 2
5111
5112
+ .. note::
5113
+
5114
+ The ``|`` operand cannot be used at runtime to define unions where one or
5115
+ more members is a forward reference. For example, ``int | "Foo"``, where
5116
+ ``"Foo"`` is a reference to a class not yet defined, will fail at
5117
+ runtime. For unions which include forward references, present the
5118
+ whole expression as a string, e.g. ``"int | Foo"``.
5119
5120
.. describe:: union_object == other
5121
5122
Union objects can be tested for equality with other union objects. Details:
0 commit comments