File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed
Filter options
Expand file tree Collapse file tree 1 file changed +8
-0
lines changed
Original file line number Diff line number Diff line change @@ -5162,6 +5162,14 @@ enables cleaner type hinting syntax compared to :data:`typing.Union`.
5162
5162
def square(number: int | float) -> int | float:
5163
5163
return number ** 2
5164
5164
5165
+ .. note ::
5166
+
5167
+ The ``| `` operand cannot be used at runtime to define unions where one or
5168
+ more members is a forward reference. For example, ``int | "Foo" ``, where
5169
+ ``"Foo" `` is a reference to a class not yet defined, will fail at
5170
+ runtime. For unions which include forward references, present the
5171
+ whole expression as a string, e.g. ``"int | Foo" ``.
5172
+
5165
5173
.. describe :: union_object == other
5166
5174
5167
5175
Union objects can be tested for equality with other union objects. Details:
You can’t perform that action at this time.
0 commit comments