Skip to content

Commit b96532f

Browse files
committed
Add secondary test for staticmethod as annotate function
1 parent ba1927c commit b96532f

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Lib/test/test_annotationlib.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1662,13 +1662,21 @@ def format(format, /, __Format=Format,
16621662
else:
16631663
raise __NotImplementedError(format)
16641664

1665+
# @staticmethod descriptor means that Annotate.format should be a function object.
16651666
annotations = annotationlib.call_annotate_function(
16661667
Annotate.format,
16671668
Format.FORWARDREF,
16681669
)
1670+
self.assertEqual(annotations, {"x": str})
16691671

1672+
# But if we access the __dict__, the underlying staticmethod object is returned.
1673+
annotations = annotationlib.call_annotate_function(
1674+
Annotate.__dict__["format"],
1675+
Format.FORWARDREF,
1676+
)
16701677
self.assertEqual(annotations, {"x": str})
16711678

1679+
16721680
def test_callable_class_annotate_forwardref_value_fallback(self):
16731681
# If Format.STRING and Format.VALUE_WITH_FAKE_GLOBALS are not
16741682
# supported fall back to Format.VALUE and convert to strings

0 commit comments

Comments
 (0)