@@ -185,7 +185,7 @@ def test_cannot_subclass(self):
185
185
class A (self .bottom_type ):
186
186
pass
187
187
with self .assertRaisesRegex (TypeError , CANNOT_SUBCLASS_TYPE ):
188
- class A (type (self .bottom_type )):
188
+ class B (type (self .bottom_type )):
189
189
pass
190
190
191
191
def test_cannot_instantiate (self ):
@@ -282,7 +282,7 @@ class C(type(Self)):
282
282
pass
283
283
with self .assertRaisesRegex (TypeError ,
284
284
r'Cannot subclass typing\.Self' ):
285
- class C (Self ):
285
+ class D (Self ):
286
286
pass
287
287
288
288
def test_cannot_init (self ):
@@ -339,7 +339,7 @@ class C(type(LiteralString)):
339
339
pass
340
340
with self .assertRaisesRegex (TypeError ,
341
341
r'Cannot subclass typing\.LiteralString' ):
342
- class C (LiteralString ):
342
+ class D (LiteralString ):
343
343
pass
344
344
345
345
def test_cannot_init (self ):
@@ -483,7 +483,7 @@ class V(TypeVar): pass
483
483
T = TypeVar ("T" )
484
484
with self .assertRaisesRegex (TypeError ,
485
485
CANNOT_SUBCLASS_INSTANCE % 'TypeVar' ):
486
- class V (T ): pass
486
+ class W (T ): pass
487
487
488
488
def test_cannot_instantiate_vars (self ):
489
489
with self .assertRaises (TypeError ):
@@ -1244,20 +1244,20 @@ class C(TypeVarTuple): pass
1244
1244
Ts = TypeVarTuple ('Ts' )
1245
1245
with self .assertRaisesRegex (TypeError ,
1246
1246
CANNOT_SUBCLASS_INSTANCE % 'TypeVarTuple' ):
1247
- class C (Ts ): pass
1247
+ class D (Ts ): pass
1248
1248
with self .assertRaisesRegex (TypeError , CANNOT_SUBCLASS_TYPE ):
1249
- class C (type (Unpack )): pass
1249
+ class E (type (Unpack )): pass
1250
1250
with self .assertRaisesRegex (TypeError , CANNOT_SUBCLASS_TYPE ):
1251
- class C (type (* Ts )): pass
1251
+ class F (type (* Ts )): pass
1252
1252
with self .assertRaisesRegex (TypeError , CANNOT_SUBCLASS_TYPE ):
1253
- class C (type (Unpack [Ts ])): pass
1253
+ class G (type (Unpack [Ts ])): pass
1254
1254
with self .assertRaisesRegex (TypeError ,
1255
1255
r'Cannot subclass typing\.Unpack' ):
1256
- class C (Unpack ): pass
1256
+ class H (Unpack ): pass
1257
1257
with self .assertRaisesRegex (TypeError , r'Cannot subclass typing.Unpack\[Ts\]' ):
1258
- class C (* Ts ): pass
1258
+ class I (* Ts ): pass
1259
1259
with self .assertRaisesRegex (TypeError , r'Cannot subclass typing.Unpack\[Ts\]' ):
1260
- class C (Unpack [Ts ]): pass
1260
+ class J (Unpack [Ts ]): pass
1261
1261
1262
1262
def test_variadic_class_args_are_correct (self ):
1263
1263
T = TypeVar ('T' )
@@ -1431,12 +1431,12 @@ def test_variadic_class_with_duplicate_typevartuples_fails(self):
1431
1431
with self .assertRaises (TypeError ):
1432
1432
class C (Generic [* Ts1 , * Ts1 ]): pass
1433
1433
with self .assertRaises (TypeError ):
1434
- class C (Generic [Unpack [Ts1 ], Unpack [Ts1 ]]): pass
1434
+ class D (Generic [Unpack [Ts1 ], Unpack [Ts1 ]]): pass
1435
1435
1436
1436
with self .assertRaises (TypeError ):
1437
- class C (Generic [* Ts1 , * Ts2 , * Ts1 ]): pass
1437
+ class E (Generic [* Ts1 , * Ts2 , * Ts1 ]): pass
1438
1438
with self .assertRaises (TypeError ):
1439
- class C (Generic [Unpack [Ts1 ], Unpack [Ts2 ], Unpack [Ts1 ]]): pass
1439
+ class F (Generic [Unpack [Ts1 ], Unpack [Ts2 ], Unpack [Ts1 ]]): pass
1440
1440
1441
1441
def test_type_concatenation_in_variadic_class_argument_list_succeeds (self ):
1442
1442
Ts = TypeVarTuple ('Ts' )
@@ -1804,11 +1804,11 @@ def test_cannot_subclass(self):
1804
1804
class C (Union ):
1805
1805
pass
1806
1806
with self .assertRaisesRegex (TypeError , CANNOT_SUBCLASS_TYPE ):
1807
- class C (type (Union )):
1807
+ class D (type (Union )):
1808
1808
pass
1809
1809
with self .assertRaisesRegex (TypeError ,
1810
1810
r'Cannot subclass typing\.Union\[int, str\]' ):
1811
- class C (Union [int , str ]):
1811
+ class E (Union [int , str ]):
1812
1812
pass
1813
1813
1814
1814
def test_cannot_instantiate (self ):
@@ -2557,10 +2557,10 @@ class BP(Protocol): pass
2557
2557
class P (C , Protocol ):
2558
2558
pass
2559
2559
with self .assertRaises (TypeError ):
2560
- class P (Protocol , C ):
2560
+ class Q (Protocol , C ):
2561
2561
pass
2562
2562
with self .assertRaises (TypeError ):
2563
- class P (BP , C , Protocol ):
2563
+ class R (BP , C , Protocol ):
2564
2564
pass
2565
2565
2566
2566
class D (BP , C ): pass
@@ -2836,7 +2836,7 @@ class NotAProtocolButAnImplicitSubclass3:
2836
2836
meth : Callable [[], None ]
2837
2837
meth2 : Callable [[int , str ], bool ]
2838
2838
def meth (self ): pass
2839
- def meth (self , x , y ): return True
2839
+ def meth2 (self , x , y ): return True
2840
2840
2841
2841
self .assertNotIsSubclass (AnnotatedButNotAProtocol , CallableMembersProto )
2842
2842
self .assertIsSubclass (NotAProtocolButAnImplicitSubclass , CallableMembersProto )
@@ -3658,11 +3658,11 @@ def test_protocols_bad_subscripts(self):
3658
3658
with self .assertRaises (TypeError ):
3659
3659
class P (Protocol [T , T ]): pass
3660
3660
with self .assertRaises (TypeError ):
3661
- class P (Protocol [int ]): pass
3661
+ class Q (Protocol [int ]): pass
3662
3662
with self .assertRaises (TypeError ):
3663
- class P (Protocol [T ], Protocol [S ]): pass
3663
+ class R (Protocol [T ], Protocol [S ]): pass
3664
3664
with self .assertRaises (TypeError ):
3665
- class P (typing .Mapping [T , S ], Protocol [T ]): pass
3665
+ class S (typing .Mapping [T , S ], Protocol [T ]): pass
3666
3666
3667
3667
def test_generic_protocols_repr (self ):
3668
3668
T = TypeVar ('T' )
@@ -4094,12 +4094,12 @@ class NewGeneric(Generic): ...
4094
4094
with self .assertRaises (TypeError ):
4095
4095
class MyGeneric (Generic [T ], Generic [S ]): ...
4096
4096
with self .assertRaises (TypeError ):
4097
- class MyGeneric (List [T ], Generic [S ]): ...
4097
+ class MyGeneric2 (List [T ], Generic [S ]): ...
4098
4098
with self .assertRaises (TypeError ):
4099
4099
Generic [()]
4100
- class C (Generic [T ]): pass
4100
+ class D (Generic [T ]): pass
4101
4101
with self .assertRaises (TypeError ):
4102
- C [()]
4102
+ D [()]
4103
4103
4104
4104
def test_generic_subclass_checks (self ):
4105
4105
for typ in [list [int ], List [int ],
@@ -4836,7 +4836,7 @@ class Test(Generic[T], Final):
4836
4836
class Subclass (Test ):
4837
4837
pass
4838
4838
with self .assertRaises (FinalException ):
4839
- class Subclass (Test [int ]):
4839
+ class Subclass2 (Test [int ]):
4840
4840
pass
4841
4841
4842
4842
def test_nested (self ):
@@ -5074,15 +5074,15 @@ def test_cannot_subclass(self):
5074
5074
class C (type (ClassVar )):
5075
5075
pass
5076
5076
with self .assertRaisesRegex (TypeError , CANNOT_SUBCLASS_TYPE ):
5077
- class C (type (ClassVar [int ])):
5077
+ class D (type (ClassVar [int ])):
5078
5078
pass
5079
5079
with self .assertRaisesRegex (TypeError ,
5080
5080
r'Cannot subclass typing\.ClassVar' ):
5081
- class C (ClassVar ):
5081
+ class E (ClassVar ):
5082
5082
pass
5083
5083
with self .assertRaisesRegex (TypeError ,
5084
5084
r'Cannot subclass typing\.ClassVar\[int\]' ):
5085
- class C (ClassVar [int ]):
5085
+ class F (ClassVar [int ]):
5086
5086
pass
5087
5087
5088
5088
def test_cannot_init (self ):
@@ -5124,15 +5124,15 @@ def test_cannot_subclass(self):
5124
5124
class C (type (Final )):
5125
5125
pass
5126
5126
with self .assertRaisesRegex (TypeError , CANNOT_SUBCLASS_TYPE ):
5127
- class C (type (Final [int ])):
5127
+ class D (type (Final [int ])):
5128
5128
pass
5129
5129
with self .assertRaisesRegex (TypeError ,
5130
5130
r'Cannot subclass typing\.Final' ):
5131
- class C (Final ):
5131
+ class E (Final ):
5132
5132
pass
5133
5133
with self .assertRaisesRegex (TypeError ,
5134
5134
r'Cannot subclass typing\.Final\[int\]' ):
5135
- class C (Final [int ]):
5135
+ class F (Final [int ]):
5136
5136
pass
5137
5137
5138
5138
def test_cannot_init (self ):
@@ -7265,15 +7265,15 @@ class A:
7265
7265
class X (NamedTuple , A ):
7266
7266
x : int
7267
7267
with self .assertRaises (TypeError ):
7268
- class X (NamedTuple , tuple ):
7268
+ class Y (NamedTuple , tuple ):
7269
7269
x : int
7270
7270
with self .assertRaises (TypeError ):
7271
- class X (NamedTuple , NamedTuple ):
7271
+ class Z (NamedTuple , NamedTuple ):
7272
7272
x : int
7273
- class A (NamedTuple ):
7273
+ class B (NamedTuple ):
7274
7274
x : int
7275
7275
with self .assertRaises (TypeError ):
7276
- class X (NamedTuple , A ):
7276
+ class C (NamedTuple , B ):
7277
7277
y : str
7278
7278
7279
7279
def test_generic (self ):
@@ -8037,15 +8037,15 @@ def test_cannot_subclass(self):
8037
8037
class C (type (Required )):
8038
8038
pass
8039
8039
with self .assertRaisesRegex (TypeError , CANNOT_SUBCLASS_TYPE ):
8040
- class C (type (Required [int ])):
8040
+ class D (type (Required [int ])):
8041
8041
pass
8042
8042
with self .assertRaisesRegex (TypeError ,
8043
8043
r'Cannot subclass typing\.Required' ):
8044
- class C (Required ):
8044
+ class E (Required ):
8045
8045
pass
8046
8046
with self .assertRaisesRegex (TypeError ,
8047
8047
r'Cannot subclass typing\.Required\[int\]' ):
8048
- class C (Required [int ]):
8048
+ class F (Required [int ]):
8049
8049
pass
8050
8050
8051
8051
def test_cannot_init (self ):
@@ -8085,15 +8085,15 @@ def test_cannot_subclass(self):
8085
8085
class C (type (NotRequired )):
8086
8086
pass
8087
8087
with self .assertRaisesRegex (TypeError , CANNOT_SUBCLASS_TYPE ):
8088
- class C (type (NotRequired [int ])):
8088
+ class D (type (NotRequired [int ])):
8089
8089
pass
8090
8090
with self .assertRaisesRegex (TypeError ,
8091
8091
r'Cannot subclass typing\.NotRequired' ):
8092
- class C (NotRequired ):
8092
+ class E (NotRequired ):
8093
8093
pass
8094
8094
with self .assertRaisesRegex (TypeError ,
8095
8095
r'Cannot subclass typing\.NotRequired\[int\]' ):
8096
- class C (NotRequired [int ]):
8096
+ class F (NotRequired [int ]):
8097
8097
pass
8098
8098
8099
8099
def test_cannot_init (self ):
@@ -8192,7 +8192,7 @@ class A(typing.Match):
8192
8192
TypeError ,
8193
8193
r"type 're\.Pattern' is not an acceptable base type" ,
8194
8194
):
8195
- class A (typing .Pattern ):
8195
+ class B (typing .Pattern ):
8196
8196
pass
8197
8197
8198
8198
@@ -8539,7 +8539,7 @@ class C(TypeAlias):
8539
8539
pass
8540
8540
8541
8541
with self .assertRaises (TypeError ):
8542
- class C (type (TypeAlias )):
8542
+ class D (type (TypeAlias )):
8543
8543
pass
8544
8544
8545
8545
def test_repr (self ):
@@ -8929,19 +8929,19 @@ def test_cannot_subclass(self):
8929
8929
with self .assertRaisesRegex (TypeError , NOT_A_BASE_TYPE % 'ParamSpec' ):
8930
8930
class C (ParamSpec ): pass
8931
8931
with self .assertRaisesRegex (TypeError , NOT_A_BASE_TYPE % 'ParamSpecArgs' ):
8932
- class C (ParamSpecArgs ): pass
8932
+ class D (ParamSpecArgs ): pass
8933
8933
with self .assertRaisesRegex (TypeError , NOT_A_BASE_TYPE % 'ParamSpecKwargs' ):
8934
- class C (ParamSpecKwargs ): pass
8934
+ class E (ParamSpecKwargs ): pass
8935
8935
P = ParamSpec ('P' )
8936
8936
with self .assertRaisesRegex (TypeError ,
8937
8937
CANNOT_SUBCLASS_INSTANCE % 'ParamSpec' ):
8938
- class C (P ): pass
8938
+ class F (P ): pass
8939
8939
with self .assertRaisesRegex (TypeError ,
8940
8940
CANNOT_SUBCLASS_INSTANCE % 'ParamSpecArgs' ):
8941
- class C (P .args ): pass
8941
+ class G (P .args ): pass
8942
8942
with self .assertRaisesRegex (TypeError ,
8943
8943
CANNOT_SUBCLASS_INSTANCE % 'ParamSpecKwargs' ):
8944
- class C (P .kwargs ): pass
8944
+ class H (P .kwargs ): pass
8945
8945
8946
8946
8947
8947
class ConcatenateTests (BaseTestCase ):
@@ -9022,15 +9022,15 @@ def test_cannot_subclass(self):
9022
9022
class C (type (TypeGuard )):
9023
9023
pass
9024
9024
with self .assertRaisesRegex (TypeError , CANNOT_SUBCLASS_TYPE ):
9025
- class C (type (TypeGuard [int ])):
9025
+ class D (type (TypeGuard [int ])):
9026
9026
pass
9027
9027
with self .assertRaisesRegex (TypeError ,
9028
9028
r'Cannot subclass typing\.TypeGuard' ):
9029
- class C (TypeGuard ):
9029
+ class E (TypeGuard ):
9030
9030
pass
9031
9031
with self .assertRaisesRegex (TypeError ,
9032
9032
r'Cannot subclass typing\.TypeGuard\[int\]' ):
9033
- class C (TypeGuard [int ]):
9033
+ class F (TypeGuard [int ]):
9034
9034
pass
9035
9035
9036
9036
def test_cannot_init (self ):
0 commit comments