Skip to content

Commit 14c5bd3

Browse files
committed
add test
1 parent 65f640c commit 14c5bd3

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

Lib/test/test_annotationlib.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,6 +1222,23 @@ class ConditionalAnnotations:
12221222
{"x": "int"},
12231223
)
12241224

1225+
def test_conditional_annotations_forwardref(self):
1226+
class ConditionalForwardRef:
1227+
a: object.undefined
1228+
if False:
1229+
b: str
1230+
1231+
self.assertEqual(
1232+
get_annotations(ConditionalForwardRef, format=Format.FORWARDREF),
1233+
{"a": support.EqualToForwardRef(
1234+
"object.undefined", is_class=True, owner=ConditionalForwardRef
1235+
)},
1236+
)
1237+
self.assertEqual(
1238+
get_annotations(ConditionalForwardRef, format=Format.STRING),
1239+
{"a": "object.undefined"},
1240+
)
1241+
12251242
def test_pep695_generic_class_with_future_annotations(self):
12261243
ann_module695 = inspect_stringized_annotations_pep695
12271244
A_annotations = get_annotations(ann_module695.A, eval_str=True)

0 commit comments

Comments
 (0)