@@ -183,7 +183,7 @@ def test_cannot_subclass(self):
183
183
class A (self .bottom_type ):
184
184
pass
185
185
with self .assertRaises (TypeError ):
186
- class A (type (self .bottom_type )):
186
+ class B (type (self .bottom_type )):
187
187
pass
188
188
189
189
def test_cannot_instantiate (self ):
@@ -279,7 +279,7 @@ def test_cannot_subclass(self):
279
279
class C (type (Self )):
280
280
pass
281
281
with self .assertRaises (TypeError ):
282
- class C (Self ):
282
+ class D (Self ):
283
283
pass
284
284
285
285
def test_cannot_init (self ):
@@ -335,7 +335,7 @@ def test_cannot_subclass(self):
335
335
class C (type (LiteralString )):
336
336
pass
337
337
with self .assertRaises (TypeError ):
338
- class C (LiteralString ):
338
+ class D (LiteralString ):
339
339
pass
340
340
341
341
def test_cannot_init (self ):
@@ -457,7 +457,7 @@ class V(TypeVar('T')):
457
457
458
458
def test_cannot_subclass_var_itself (self ):
459
459
with self .assertRaises (TypeError ):
460
- class V (TypeVar ):
460
+ class W (TypeVar ):
461
461
pass
462
462
463
463
def test_cannot_instantiate_vars (self ):
@@ -1185,20 +1185,20 @@ class C(TypeVarTuple): pass
1185
1185
def test_cannot_subclass_instance (self ):
1186
1186
Ts = TypeVarTuple ('Ts' )
1187
1187
with self .assertRaises (TypeError ):
1188
- class C (Ts ): pass
1188
+ class D (Ts ): pass
1189
1189
with self .assertRaisesRegex (TypeError , CANNOT_SUBCLASS_TYPE ):
1190
- class C (type (Unpack )): pass
1190
+ class E (type (Unpack )): pass
1191
1191
with self .assertRaisesRegex (TypeError , CANNOT_SUBCLASS_TYPE ):
1192
- class C (type (* Ts )): pass
1192
+ class F (type (* Ts )): pass
1193
1193
with self .assertRaisesRegex (TypeError , CANNOT_SUBCLASS_TYPE ):
1194
- class C (type (Unpack [Ts ])): pass
1194
+ class G (type (Unpack [Ts ])): pass
1195
1195
with self .assertRaisesRegex (TypeError ,
1196
1196
r'Cannot subclass typing\.Unpack' ):
1197
- class C (Unpack ): pass
1197
+ class H (Unpack ): pass
1198
1198
with self .assertRaisesRegex (TypeError , r'Cannot subclass \*Ts' ):
1199
- class C (* Ts ): pass
1199
+ class I (* Ts ): pass
1200
1200
with self .assertRaisesRegex (TypeError , r'Cannot subclass \*Ts' ):
1201
- class C (Unpack [Ts ]): pass
1201
+ class J (Unpack [Ts ]): pass
1202
1202
1203
1203
def test_variadic_class_args_are_correct (self ):
1204
1204
T = TypeVar ('T' )
@@ -1372,12 +1372,12 @@ def test_variadic_class_with_duplicate_typevartuples_fails(self):
1372
1372
with self .assertRaises (TypeError ):
1373
1373
class C (Generic [* Ts1 , * Ts1 ]): pass
1374
1374
with self .assertRaises (TypeError ):
1375
- class C (Generic [Unpack [Ts1 ], Unpack [Ts1 ]]): pass
1375
+ class D (Generic [Unpack [Ts1 ], Unpack [Ts1 ]]): pass
1376
1376
1377
1377
with self .assertRaises (TypeError ):
1378
- class C (Generic [* Ts1 , * Ts2 , * Ts1 ]): pass
1378
+ class E (Generic [* Ts1 , * Ts2 , * Ts1 ]): pass
1379
1379
with self .assertRaises (TypeError ):
1380
- class C (Generic [Unpack [Ts1 ], Unpack [Ts2 ], Unpack [Ts1 ]]): pass
1380
+ class F (Generic [Unpack [Ts1 ], Unpack [Ts2 ], Unpack [Ts1 ]]): pass
1381
1381
1382
1382
def test_type_concatenation_in_variadic_class_argument_list_succeeds (self ):
1383
1383
Ts = TypeVarTuple ('Ts' )
@@ -1744,10 +1744,10 @@ def test_cannot_subclass(self):
1744
1744
class C (Union ):
1745
1745
pass
1746
1746
with self .assertRaises (TypeError ):
1747
- class C (type (Union )):
1747
+ class D (type (Union )):
1748
1748
pass
1749
1749
with self .assertRaises (TypeError ):
1750
- class C (Union [int , str ]):
1750
+ class E (Union [int , str ]):
1751
1751
pass
1752
1752
1753
1753
def test_cannot_instantiate (self ):
@@ -2454,10 +2454,10 @@ class BP(Protocol): pass
2454
2454
class P (C , Protocol ):
2455
2455
pass
2456
2456
with self .assertRaises (TypeError ):
2457
- class P (Protocol , C ):
2457
+ class Q (Protocol , C ):
2458
2458
pass
2459
2459
with self .assertRaises (TypeError ):
2460
- class P (BP , C , Protocol ):
2460
+ class R (BP , C , Protocol ):
2461
2461
pass
2462
2462
2463
2463
class D (BP , C ): pass
@@ -2722,7 +2722,7 @@ class NotAProtocolButAnImplicitSubclass3:
2722
2722
meth : Callable [[], None ]
2723
2723
meth2 : Callable [[int , str ], bool ]
2724
2724
def meth (self ): pass
2725
- def meth (self , x , y ): return True
2725
+ def meth2 (self , x , y ): return True
2726
2726
2727
2727
self .assertNotIsSubclass (AnnotatedButNotAProtocol , CallableMembersProto )
2728
2728
self .assertIsSubclass (NotAProtocolButAnImplicitSubclass , CallableMembersProto )
@@ -3208,11 +3208,11 @@ def test_protocols_bad_subscripts(self):
3208
3208
with self .assertRaises (TypeError ):
3209
3209
class P (Protocol [T , T ]): pass
3210
3210
with self .assertRaises (TypeError ):
3211
- class P (Protocol [int ]): pass
3211
+ class Q (Protocol [int ]): pass
3212
3212
with self .assertRaises (TypeError ):
3213
- class P (Protocol [T ], Protocol [S ]): pass
3213
+ class R (Protocol [T ], Protocol [S ]): pass
3214
3214
with self .assertRaises (TypeError ):
3215
- class P (typing .Mapping [T , S ], Protocol [T ]): pass
3215
+ class S (typing .Mapping [T , S ], Protocol [T ]): pass
3216
3216
3217
3217
def test_generic_protocols_repr (self ):
3218
3218
T = TypeVar ('T' )
@@ -3553,12 +3553,12 @@ class NewGeneric(Generic): ...
3553
3553
with self .assertRaises (TypeError ):
3554
3554
class MyGeneric (Generic [T ], Generic [S ]): ...
3555
3555
with self .assertRaises (TypeError ):
3556
- class MyGeneric (List [T ], Generic [S ]): ...
3556
+ class MyGeneric2 (List [T ], Generic [S ]): ...
3557
3557
with self .assertRaises (TypeError ):
3558
3558
Generic [()]
3559
- class C (Generic [T ]): pass
3559
+ class D (Generic [T ]): pass
3560
3560
with self .assertRaises (TypeError ):
3561
- C [()]
3561
+ D [()]
3562
3562
3563
3563
def test_init (self ):
3564
3564
T = TypeVar ('T' )
@@ -4234,7 +4234,7 @@ class Test(Generic[T], Final):
4234
4234
class Subclass (Test ):
4235
4235
pass
4236
4236
with self .assertRaises (FinalException ):
4237
- class Subclass (Test [int ]):
4237
+ class Subclass2 (Test [int ]):
4238
4238
pass
4239
4239
4240
4240
def test_nested (self ):
@@ -4472,7 +4472,7 @@ def test_cannot_subclass(self):
4472
4472
class C (type (ClassVar )):
4473
4473
pass
4474
4474
with self .assertRaises (TypeError ):
4475
- class C (type (ClassVar [int ])):
4475
+ class D (type (ClassVar [int ])):
4476
4476
pass
4477
4477
4478
4478
def test_cannot_init (self ):
@@ -4514,7 +4514,7 @@ def test_cannot_subclass(self):
4514
4514
class C (type (Final )):
4515
4515
pass
4516
4516
with self .assertRaises (TypeError ):
4517
- class C (type (Final [int ])):
4517
+ class D (type (Final [int ])):
4518
4518
pass
4519
4519
4520
4520
def test_cannot_init (self ):
@@ -6514,15 +6514,15 @@ class A:
6514
6514
class X (NamedTuple , A ):
6515
6515
x : int
6516
6516
with self .assertRaises (TypeError ):
6517
- class X (NamedTuple , tuple ):
6517
+ class Y (NamedTuple , tuple ):
6518
6518
x : int
6519
6519
with self .assertRaises (TypeError ):
6520
- class X (NamedTuple , NamedTuple ):
6520
+ class Z (NamedTuple , NamedTuple ):
6521
6521
x : int
6522
- class A (NamedTuple ):
6522
+ class B (NamedTuple ):
6523
6523
x : int
6524
6524
with self .assertRaises (TypeError ):
6525
- class X (NamedTuple , A ):
6525
+ class C (NamedTuple , B ):
6526
6526
y : str
6527
6527
6528
6528
def test_generic (self ):
@@ -7108,13 +7108,13 @@ def test_cannot_subclass(self):
7108
7108
class C (type (Required )):
7109
7109
pass
7110
7110
with self .assertRaises (TypeError ):
7111
- class C (type (Required [int ])):
7111
+ class D (type (Required [int ])):
7112
7112
pass
7113
7113
with self .assertRaises (TypeError ):
7114
- class C (Required ):
7114
+ class E (Required ):
7115
7115
pass
7116
7116
with self .assertRaises (TypeError ):
7117
- class C (Required [int ]):
7117
+ class F (Required [int ]):
7118
7118
pass
7119
7119
7120
7120
def test_cannot_init (self ):
@@ -7154,13 +7154,13 @@ def test_cannot_subclass(self):
7154
7154
class C (type (NotRequired )):
7155
7155
pass
7156
7156
with self .assertRaises (TypeError ):
7157
- class C (type (NotRequired [int ])):
7157
+ class D (type (NotRequired [int ])):
7158
7158
pass
7159
7159
with self .assertRaises (TypeError ):
7160
- class C (NotRequired ):
7160
+ class E (NotRequired ):
7161
7161
pass
7162
7162
with self .assertRaises (TypeError ):
7163
- class C (NotRequired [int ]):
7163
+ class F (NotRequired [int ]):
7164
7164
pass
7165
7165
7166
7166
def test_cannot_init (self ):
@@ -7622,7 +7622,7 @@ class C(TypeAlias):
7622
7622
pass
7623
7623
7624
7624
with self .assertRaises (TypeError ):
7625
- class C (type (TypeAlias )):
7625
+ class D (type (TypeAlias )):
7626
7626
pass
7627
7627
7628
7628
def test_repr (self ):
@@ -8078,7 +8078,7 @@ def test_cannot_subclass(self):
8078
8078
class C (type (TypeGuard )):
8079
8079
pass
8080
8080
with self .assertRaises (TypeError ):
8081
- class C (type (TypeGuard [int ])):
8081
+ class D (type (TypeGuard [int ])):
8082
8082
pass
8083
8083
8084
8084
def test_cannot_init (self ):
0 commit comments