File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
Filter options
Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
Original file line number Diff line number Diff line change @@ -936,6 +936,28 @@ def __call__(self):
936
936
annotationlib .get_annotations (obj , format = format ), {}
937
937
)
938
938
939
+ def test_union_forwardref (self ):
940
+ # Test unions with '|' syntax equal unions with typing.Union[] with forwardrefs
941
+ class UnionForwardrefs :
942
+ pipe : str | undefined
943
+ union : Union [str , undefined ]
944
+
945
+ annos = get_annotations (UnionForwardrefs , format = Format .FORWARDREF )
946
+
947
+ match = (
948
+ str ,
949
+ support .EqualToForwardRef ("undefined" , is_class = True , owner = UnionForwardrefs )
950
+ )
951
+
952
+ self .assertEqual (
953
+ typing .get_args (annos ["pipe" ]),
954
+ typing .get_args (annos ["union" ])
955
+ )
956
+
957
+ self .assertEqual (typing .get_args (annos ["pipe" ]), match )
958
+ self .assertEqual (typing .get_args (annos ["union" ]), match )
959
+
960
+
939
961
def test_pep695_generic_class_with_future_annotations (self ):
940
962
ann_module695 = inspect_stringized_annotations_pep695
941
963
A_annotations = annotationlib .get_annotations (ann_module695 .A , eval_str = True )
You can’t perform that action at this time.
0 commit comments