6464)
6565
6666ANN_MODULE_SOURCE = '''\
67+ import sys
6768from typing import List, Optional
6869from functools import wraps
6970
70- __annotations__[1] = 2
71+ try:
72+ __annotations__[1] = 2
73+ except NameError:
74+ assert sys.version_info >= (3, 14)
7175
7276class C:
7377
@@ -77,8 +81,10 @@ class C:
7781x: int = 5; y: str = x; f: Tuple[int, int]
7882
7983class M(type):
80-
81- __annotations__['123'] = 123
84+ try:
85+ __annotations__['123'] = 123
86+ except NameError:
87+ assert sys.version_info >= (3, 14)
8288 o: type = object
8389
8490(pars): bool = True
@@ -1310,7 +1316,10 @@ def tearDownClass(cls):
13101316 del sys .modules [modname ]
13111317
13121318 def test_get_type_hints_modules (self ):
1313- ann_module_type_hints = {1 : 2 , 'f' : Tuple [int , int ], 'x' : int , 'y' : str }
1319+ if sys .version_info >= (3 , 14 ):
1320+ ann_module_type_hints = {'f' : Tuple [int , int ], 'x' : int , 'y' : str }
1321+ else :
1322+ ann_module_type_hints = {1 : 2 , 'f' : Tuple [int , int ], 'x' : int , 'y' : str }
13141323 self .assertEqual (gth (self .ann_module ), ann_module_type_hints )
13151324 self .assertEqual (gth (self .ann_module2 ), {})
13161325 self .assertEqual (gth (self .ann_module3 ), {})
@@ -1319,7 +1328,10 @@ def test_get_type_hints_classes(self):
13191328 self .assertEqual (gth (self .ann_module .C , self .ann_module .__dict__ ),
13201329 {'y' : Optional [self .ann_module .C ]})
13211330 self .assertIsInstance (gth (self .ann_module .j_class ), dict )
1322- self .assertEqual (gth (self .ann_module .M ), {'123' : 123 , 'o' : type })
1331+ if sys .version_info >= (3 , 14 ):
1332+ self .assertEqual (gth (self .ann_module .M ), {'o' : type })
1333+ else :
1334+ self .assertEqual (gth (self .ann_module .M ), {'123' : 123 , 'o' : type })
13231335 self .assertEqual (gth (self .ann_module .D ),
13241336 {'j' : str , 'k' : str , 'y' : Optional [self .ann_module .C ]})
13251337 self .assertEqual (gth (self .ann_module .Y ), {'z' : int })
@@ -2992,7 +3004,7 @@ def meth(self): pass # noqa: B027
29923004
29933005 acceptable_extra_attrs = {
29943006 '_is_protocol' , '_is_runtime_protocol' , '__parameters__' ,
2995- '__init__' , '__annotations__' , '__subclasshook__' ,
3007+ '__init__' , '__annotations__' , '__subclasshook__' , '__annotate__'
29963008 }
29973009 self .assertLessEqual (vars (NonP ).keys (), vars (C ).keys () | acceptable_extra_attrs )
29983010 self .assertLessEqual (
0 commit comments