Skip to content

Commit 494c3e7

Browse files
committed
Address review
1 parent 12e714f commit 494c3e7

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

Lib/test/test_annotationlib.py

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -809,24 +809,6 @@ def f(x: int):
809809
{"x": "int"},
810810
)
811811

812-
def test_del_annotations(self):
813-
# gh-132285
814-
called = False
815-
class A:
816-
def __annotate__(format):
817-
nonlocal called
818-
called = True
819-
return {'a': int}
820-
821-
self.assertEqual(A.__annotations__, {'a': int})
822-
self.assertTrue(called)
823-
824-
del A.__annotations__
825-
called = False
826-
827-
self.assertEqual(A.__annotations__, {})
828-
self.assertFalse(called)
829-
830812
def test_non_dict_annotations(self):
831813
class WeirdAnnotations:
832814
@property

Lib/test/test_type_annotations.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,26 @@ class C:
5757
del C.__annotations__
5858
self.assertFalse("__annotations__" in C.__dict__)
5959

60+
def test_del_annotations_and_annotate(self):
61+
# gh-132285
62+
called = False
63+
class A:
64+
def __annotate__(format):
65+
nonlocal called
66+
called = True
67+
return {'a': int}
68+
69+
self.assertEqual(A.__annotations__, {'a': int})
70+
self.assertTrue(called)
71+
self.assertTrue(A.__annotate__)
72+
73+
del A.__annotations__
74+
called = False
75+
76+
self.assertEqual(A.__annotations__, {})
77+
self.assertFalse(called)
78+
self.assertIs(A.__annotate__, None)
79+
6080
def test_descriptor_still_works(self):
6181
class C:
6282
def __init__(self, name=None, bases=None, d=None):

0 commit comments

Comments
 (0)