@@ -3282,6 +3282,22 @@ class BadType(BadBase):
3282
3282
self .assertNotIn ('bad' , sys .modules )
3283
3283
self .assertEqual (get_type_hints (BadType ), {'foo' : tuple , 'bar' : list })
3284
3284
3285
+ def test_forward_ref_and_final (self ):
3286
+ # https://bugs.python.org/issue45166
3287
+ hints = get_type_hints (ann_module5 )
3288
+ self .assertEqual (hints , {'name' : Final [str ]})
3289
+
3290
+ hints = get_type_hints (ann_module5 .MyClass )
3291
+ self .assertEqual (hints , {'value' : Final })
3292
+
3293
+ def test_top_level_class_var (self ):
3294
+ # https://bugs.python.org/issue45166
3295
+ with self .assertRaisesRegex (
3296
+ TypeError ,
3297
+ r'typing.ClassVar\[int\] is not valid as type argument' ,
3298
+ ):
3299
+ get_type_hints (ann_module6 )
3300
+
3285
3301
3286
3302
class GetUtilitiesTestCase (TestCase ):
3287
3303
def test_get_origin (self ):
@@ -3345,22 +3361,6 @@ class C(Generic[T]): pass
3345
3361
(Concatenate [int , P ], int ))
3346
3362
self .assertEqual (get_args (list | str ), (list , str ))
3347
3363
3348
- def test_forward_ref_and_final (self ):
3349
- # https://bugs.python.org/issue45166
3350
- hints = get_type_hints (ann_module5 )
3351
- self .assertEqual (hints , {'name' : Final [str ]})
3352
-
3353
- hints = get_type_hints (ann_module5 .MyClass )
3354
- self .assertEqual (hints , {'value' : Final })
3355
-
3356
- def test_top_level_class_var (self ):
3357
- # https://bugs.python.org/issue45166
3358
- with self .assertRaisesRegex (
3359
- TypeError ,
3360
- r'typing.ClassVar\[int\] is not valid as type argument' ,
3361
- ):
3362
- get_type_hints (ann_module6 )
3363
-
3364
3364
3365
3365
class CollectionsAbcTests (BaseTestCase ):
3366
3366
0 commit comments