@@ -7523,16 +7523,32 @@ def test_subscription_without_type_params(self):
75237523 Simple [[]]
75247524 with self .assertRaises (TypeError , msg = "Only generic type aliases are subscriptable" ):
75257525 Simple [()]
7526-
7527- # no TypeVar in type_params, however in value still allows subscription
7526+
7527+ # A TypeVar in the value does not allow subscription
75287528 T = TypeVar ('T' )
7529+ MissingTypeParamsErr = TypeAliasType ("MissingTypeParamsErr" , List [T ])
7530+ self .assertEqual (MissingTypeParamsErr .__type_params__ , ())
7531+ self .assertEqual (MissingTypeParamsErr .__parameters__ , ())
7532+ with self .assertRaises (TypeError , msg = "Only generic type aliases are subscriptable" ):
7533+ MissingTypeParamsErr [int ]
7534+ with self .assertRaises (TypeError , msg = "Only generic type aliases are subscriptable" ):
7535+ MissingTypeParamsErr [[]]
7536+ with self .assertRaises (TypeError , msg = "Only generic type aliases are subscriptable" ):
7537+ MissingTypeParamsErr [()]
7538+
7539+ # However, providing type_params=() argument allows subscription
75297540 MissingTypeParams = TypeAliasType ("MissingTypeParams" , List [T ], type_params = ())
75307541 self .assertEqual (MissingTypeParams .__type_params__ , ())
75317542 self .assertEqual (MissingTypeParams .__parameters__ , ())
7532- # These should not raise:
7543+ # These do not raise
75337544 MissingTypeParams [int ]
75347545 MissingTypeParams [[]]
75357546 MissingTypeParams [()]
7547+ # These do not raise
7548+ Simple2 = TypeAliasType ("Simple2" , int , type_params = ())
7549+ Simple2 [int ]
7550+ Simple2 [[]]
7551+ Simple2 [()]
75367552
75377553 def test_pickle (self ):
75387554 global Alias
0 commit comments