@@ -7515,40 +7515,6 @@ def test_invalid_cases_before_3_11(self):
75157515 with self .assertRaises (TypeError ):
75167516 ListOrSetT [(Generic [T ], )]
75177517
7518- def test_subscription_without_type_params (self ):
7519- Simple = TypeAliasType ("Simple" , int )
7520- with self .assertRaises (TypeError , msg = "Only generic type aliases are subscriptable" ):
7521- Simple [int ]
7522- with self .assertRaises (TypeError , msg = "Only generic type aliases are subscriptable" ):
7523- Simple [[]]
7524- with self .assertRaises (TypeError , msg = "Only generic type aliases are subscriptable" ):
7525- Simple [()]
7526-
7527- # A TypeVar in the value does not allow subscription
7528- 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
7540- MissingTypeParams = TypeAliasType ("MissingTypeParams" , List [T ], type_params = ())
7541- self .assertEqual (MissingTypeParams .__type_params__ , ())
7542- self .assertEqual (MissingTypeParams .__parameters__ , ())
7543- # These do not raise
7544- MissingTypeParams [int ]
7545- MissingTypeParams [[]]
7546- MissingTypeParams [()]
7547- # These do not raise
7548- Simple2 = TypeAliasType ("Simple2" , int , type_params = ())
7549- Simple2 [int ]
7550- Simple2 [[]]
7551- Simple2 [()]
75527518
75537519 def test_pickle (self ):
75547520 global Alias
0 commit comments