-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Expand file tree
/
Copy pathcheck-python313.test
More file actions
498 lines (388 loc) · 19.6 KB
/
check-python313.test
File metadata and controls
498 lines (388 loc) · 19.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
[case testPEP695TypeParameterDefaultSupported]
class C[T = None]: ...
def f[T = list[int]]() -> None: ...
def g[**P = [int, str]]() -> None: ...
type A[T, S = int, U = str] = list[T]
[case testPEP695TypeParameterDefaultBasic]
from typing import Callable
def f1[T1 = int](a: T1) -> list[T1]: ...
reveal_type(f1) # N: Revealed type is "def [T1 = builtins.int] (a: T1`-1 = builtins.int) -> builtins.list[T1`-1 = builtins.int]"
def f2[**P1 = [int, str]](a: Callable[P1, None]) -> Callable[P1, None]: ...
reveal_type(f2) # N: Revealed type is "def [P1 = [builtins.int, builtins.str]] (a: def (*P1.args, **P1.kwargs)) -> def (*P1.args, **P1.kwargs)"
def f3[*Ts1 = *tuple[int, str]](a: tuple[*Ts1]) -> tuple[*Ts1]: ...
reveal_type(f3) # N: Revealed type is "def [Ts1 = Unpack[tuple[builtins.int, builtins.str]]] (a: tuple[Unpack[Ts1`-1 = Unpack[tuple[builtins.int, builtins.str]]]]) -> tuple[Unpack[Ts1`-1 = Unpack[tuple[builtins.int, builtins.str]]]]"
class ClassA1[T1 = int]: ...
class ClassA2[**P1 = [int, str]]: ...
class ClassA3[*Ts1 = *tuple[int, str]]: ...
reveal_type(ClassA1) # N: Revealed type is "def [T1 = builtins.int] () -> __main__.ClassA1[T1`1 = builtins.int]"
reveal_type(ClassA2) # N: Revealed type is "def [P1 = [builtins.int, builtins.str]] () -> __main__.ClassA2[P1`1 = [builtins.int, builtins.str]]"
reveal_type(ClassA3) # N: Revealed type is "def [Ts1 = Unpack[tuple[builtins.int, builtins.str]]] () -> __main__.ClassA3[Unpack[Ts1`1 = Unpack[tuple[builtins.int, builtins.str]]]]"
[builtins fixtures/tuple.pyi]
[case testPEP695TypeParameterDefaultValid]
from typing import Any
class ClassT1[T = int]: ...
class ClassT2[T: float = int]: ...
class ClassT3[T: list[Any] = list[int]]: ...
class ClassT4[T: (int, str) = int]: ...
class ClassP1[**P = []]: ...
class ClassP2[**P = ...]: ...
class ClassP3[**P = [int, str]]: ...
class ClassTs1[*Ts = *tuple[int]]: ...
class ClassTs2[*Ts = *tuple[int, ...]]: ...
[builtins fixtures/tuple.pyi]
[case testPEP695TypeParameterDefaultInvalid]
class ClassT1[T = 2]: ... # E: TypeVar "default" must be a type
class ClassT2[T = [int]]: ... # E: Bracketed expression "[...]" is not valid as a type \
# N: Did you mean "List[...]"? \
# E: TypeVar "default" must be a type
class ClassT3[T: str = int]: ... # E: TypeVar default must be a subtype of the bound type
class ClassT4[T: list[str] = list[int]]: ... # E: TypeVar default must be a subtype of the bound type
class ClassT5[T: (int, str) = bytes]: ... # E: TypeVar default must be one of the constraint types
class ClassT6[T: (int, str) = int | str]: ... # E: TypeVar default must be one of the constraint types
class ClassT7[T: (float, str) = int]: ... # E: TypeVar default must be one of the constraint types
class ClassP1[**P = int]: ... # E: The default argument to ParamSpec must be a list expression, ellipsis, or a ParamSpec
class ClassP2[**P = 2]: ... # E: The default argument to ParamSpec must be a list expression, ellipsis, or a ParamSpec
class ClassP3[**P = (2, int)]: ... # E: The default argument to ParamSpec must be a list expression, ellipsis, or a ParamSpec
class ClassP4[**P = [2, int]]: ... # E: Argument 0 of ParamSpec default must be a type
class ClassTs1[*Ts = 2]: ... # E: The default argument to TypeVarTuple must be an Unpacked tuple
class ClassTs2[*Ts = int]: ... # E: The default argument to TypeVarTuple must be an Unpacked tuple
class ClassTs3[*Ts = tuple[int]]: ... # E: The default argument to TypeVarTuple must be an Unpacked tuple
[builtins fixtures/tuple.pyi]
[case testPEP695TypeParameterDefaultInvalid2]
from typing import overload
def f1[T = 2]() -> None: ... # E: TypeVar "default" must be a type
def f2[T = [int]]() -> None: ... # E: Bracketed expression "[...]" is not valid as a type \
# N: Did you mean "List[...]"? \
# E: TypeVar "default" must be a type
def f3[T: str = int](x: T) -> T: ... # E: TypeVar default must be a subtype of the bound type
def f4[T: list[str] = list[int]](x: T) -> T: ... # E: TypeVar default must be a subtype of the bound type
def f5[T: (int, str) = bytes](x: T) -> T: ... # E: TypeVar default must be one of the constraint types
def f6[T: (int, str) = int | str](x: T) -> T: ... # E: TypeVar default must be one of the constraint types
def f7[T: (float, str) = int](x: T) -> T: ... # E: TypeVar default must be one of the constraint types
def f8[T: str = int]() -> None: ... # TODO check unused TypeVars
@overload
def f9[T: str = int](x: T) -> T: ... # E: TypeVar default must be a subtype of the bound type
@overload
def f9[T: (int, str) = bytes](x: T) -> T: ... # E: TypeVar default must be one of the constraint types
def f9() -> None: ... # type: ignore[misc]
def g1[**P = int]() -> None: ... # E: The default argument to ParamSpec must be a list expression, ellipsis, or a ParamSpec
def g2[**P = 2]() -> None: ... # E: The default argument to ParamSpec must be a list expression, ellipsis, or a ParamSpec
def g3[**P = (2, int)]() -> None: ... # E: The default argument to ParamSpec must be a list expression, ellipsis, or a ParamSpec
def g4[**P = [2, int]]() -> None: ... # E: Argument 0 of ParamSpec default must be a type
def h1[*Ts = 2]() -> None: ... # E: The default argument to TypeVarTuple must be an Unpacked tuple
def h2[*Ts = int]() -> None: ... # E: The default argument to TypeVarTuple must be an Unpacked tuple
def h3[*Ts = tuple[int]]() -> None: ... # E: The default argument to TypeVarTuple must be an Unpacked tuple
[builtins fixtures/tuple.pyi]
[case testPEP695TypeParameterDefaultInvalid3]
from typing import Callable
type TA1[T: str = 1] = list[T] # E: TypeVar "default" must be a type
type TA2[T: str = [int]] = list[T] # E: Bracketed expression "[...]" is not valid as a type \
# N: Did you mean "List[...]"? \
# E: TypeVar "default" must be a type
type TA3[T: str = int] = list[T] # E: TypeVar default must be a subtype of the bound type
type TA4[T: list[str] = list[int]] = list[T] # E: TypeVar default must be a subtype of the bound type
type TA5[T: (int, str) = bytes] = list[T] # E: TypeVar default must be one of the constraint types
type TA6[T: (int, str) = int | str] = list[T] # E: TypeVar default must be one of the constraint types
type TA7[T: (float, str) = int] = list[T] # E: TypeVar default must be one of the constraint types
type TB1[**P = int] = Callable[P, None] # E: The default argument to ParamSpec must be a list expression, ellipsis, or a ParamSpec
type TB2[**P = 2] = Callable[P, None] # E: The default argument to ParamSpec must be a list expression, ellipsis, or a ParamSpec
type TB3[**P = (2, int)] = Callable[P, None] # E: The default argument to ParamSpec must be a list expression, ellipsis, or a ParamSpec
type TB4[**P = [2, int]] = Callable[P, None] # E: Argument 0 of ParamSpec default must be a type
type TC1[*Ts = 2] = tuple[*Ts] # E: The default argument to TypeVarTuple must be an Unpacked tuple
type TC2[*Ts = int] = tuple[*Ts] # E: The default argument to TypeVarTuple must be an Unpacked tuple
type TC3[*Ts = tuple[int]] = tuple[*Ts] # E: The default argument to TypeVarTuple must be an Unpacked tuple
[builtins fixtures/tuple.pyi]
[typing fixtures/typing-full.pyi]
[case testPEP695TypeParameterDefaultFunctions]
from typing import Callable
def callback1(x: str) -> None: ...
def func_a1[T = str](x: int | T) -> T: ...
reveal_type(func_a1(2)) # N: Revealed type is "builtins.str"
reveal_type(func_a1(2.1)) # N: Revealed type is "builtins.float"
def func_a2[T = str](x: int | T) -> list[T]: ...
reveal_type(func_a2(2)) # N: Revealed type is "builtins.list[builtins.str]"
reveal_type(func_a2(2.1)) # N: Revealed type is "builtins.list[builtins.float]"
def func_a3[T: str = str](x: int | T) -> T: ...
reveal_type(func_a3(2)) # N: Revealed type is "builtins.str"
def func_a4[T: (bytes, str) = str](x: int | T) -> T: ...
reveal_type(func_a4(2)) # N: Revealed type is "builtins.str"
def func_b1[**P = [int, str]](x: int | Callable[P, None]) -> Callable[P, None]: ...
reveal_type(func_b1(callback1)) # N: Revealed type is "def (x: builtins.str)"
reveal_type(func_b1(2)) # N: Revealed type is "def (builtins.int, builtins.str)"
def func_c1[*Ts = *tuple[int, str]](x: int | Callable[[*Ts], None]) -> tuple[*Ts]: ...
reveal_type(func_c1(callback1)) # N: Revealed type is "tuple[builtins.str]"
reveal_type(func_c1(2)) # N: Revealed type is "tuple[builtins.int, builtins.str]"
[builtins fixtures/tuple.pyi]
[case testPEP695TypeParameterDefaultClass1]
# flags: --disallow-any-generics
class ClassA1[T2 = int, T3 = str]: ...
def func_a1(
a: ClassA1,
b: ClassA1[float],
c: ClassA1[float, float],
d: ClassA1[float, float, float], # E: "ClassA1" expects between 0 and 2 type arguments, but 3 given
) -> None:
reveal_type(a) # N: Revealed type is "__main__.ClassA1[builtins.int, builtins.str]"
reveal_type(b) # N: Revealed type is "__main__.ClassA1[builtins.float, builtins.str]"
reveal_type(c) # N: Revealed type is "__main__.ClassA1[builtins.float, builtins.float]"
reveal_type(d) # N: Revealed type is "__main__.ClassA1[builtins.int, builtins.str]"
[builtins fixtures/tuple.pyi]
[case testPEP695TypeParameterDefaultClass2]
# flags: --disallow-any-generics
class ClassB1[**P2 = [int, str], **P3 = ...]: ...
def func_b1(
a: ClassB1,
b: ClassB1[[float]],
c: ClassB1[[float], [float]],
d: ClassB1[[float], [float], [float]], # E: "ClassB1" expects between 0 and 2 type arguments, but 3 given
) -> None:
reveal_type(a) # N: Revealed type is "__main__.ClassB1[[builtins.int, builtins.str], ...]"
reveal_type(b) # N: Revealed type is "__main__.ClassB1[[builtins.float], ...]"
reveal_type(c) # N: Revealed type is "__main__.ClassB1[[builtins.float], [builtins.float]]"
reveal_type(d) # N: Revealed type is "__main__.ClassB1[[builtins.int, builtins.str], ...]"
k = ClassB1()
reveal_type(k) # N: Revealed type is "__main__.ClassB1[[builtins.int, builtins.str], [*Any, **Any]]"
l = ClassB1[[float]]()
reveal_type(l) # N: Revealed type is "__main__.ClassB1[[builtins.float], [*Any, **Any]]"
m = ClassB1[[float], [float]]()
reveal_type(m) # N: Revealed type is "__main__.ClassB1[[builtins.float], [builtins.float]]"
n = ClassB1[[float], [float], [float]]() # E: Type application has too many types (expected between 0 and 2)
reveal_type(n) # N: Revealed type is "Any"
[case testPEP695TypeParameterDefaultClass3]
# flags: --disallow-any-generics
class ClassC1[*Ts = *tuple[int, str]]: ...
def func_c1(
a: ClassC1,
b: ClassC1[float],
) -> None:
reveal_type(a) # N: Revealed type is "__main__.ClassC1[builtins.int, builtins.str]"
reveal_type(b) # N: Revealed type is "__main__.ClassC1[builtins.float]"
k = ClassC1()
reveal_type(k) # N: Revealed type is "__main__.ClassC1[builtins.int, builtins.str]"
l = ClassC1[float]()
reveal_type(l) # N: Revealed type is "__main__.ClassC1[builtins.float]"
[builtins fixtures/tuple.pyi]
[case testPEP695TypeParameterDefaultTypeAlias1]
# flags: --disallow-any-generics
type TA1[T2 = int, T3 = str] = dict[T2, T3]
def func_a1(
a: TA1,
b: TA1[float],
c: TA1[float, float],
d: TA1[float, float, float], # E: Bad number of arguments for type alias, expected between 0 and 2, given 3
) -> None:
reveal_type(a) # N: Revealed type is "builtins.dict[builtins.int, builtins.str]"
reveal_type(b) # N: Revealed type is "builtins.dict[builtins.float, builtins.str]"
reveal_type(c) # N: Revealed type is "builtins.dict[builtins.float, builtins.float]"
reveal_type(d) # N: Revealed type is "builtins.dict[builtins.int, builtins.str]"
[builtins fixtures/dict.pyi]
[typing fixtures/typing-full.pyi]
[case testPEP695TypeParameterDefaultTypeAlias2]
# flags: --disallow-any-generics
class ClassB1[**P2, **P3]: ...
type TB1[**P2 = [int, str], **P3 = ...] = ClassB1[P2, P3]
def func_b1(
a: TB1,
b: TB1[[float]],
c: TB1[[float], [float]],
d: TB1[[float], [float], [float]], # E: Bad number of arguments for type alias, expected between 0 and 2, given 3
) -> None:
reveal_type(a) # N: Revealed type is "__main__.ClassB1[[builtins.int, builtins.str], [*Any, **Any]]"
reveal_type(b) # N: Revealed type is "__main__.ClassB1[[builtins.float], [*Any, **Any]]"
reveal_type(c) # N: Revealed type is "__main__.ClassB1[[builtins.float], [builtins.float]]"
reveal_type(d) # N: Revealed type is "__main__.ClassB1[[builtins.int, builtins.str], [*Any, **Any]]"
[builtins fixtures/tuple.pyi]
[typing fixtures/typing-full.pyi]
[case testPEP695TypeParameterDefaultTypeAlias3]
# flags: --disallow-any-generics
type TC1[*Ts = *tuple[int, str]] = tuple[*Ts]
def func_c1(
a: TC1,
b: TC1[float],
) -> None:
reveal_type(a) # N: Revealed type is "tuple[builtins.int, builtins.str]"
reveal_type(b) # N: Revealed type is "tuple[builtins.float]"
[builtins fixtures/tuple.pyi]
[typing fixtures/typing-full.pyi]
[case testPEP695TypeParameterDefaultTypeAlias4]
# flags: --disallow-any-generics
class A[L = int, M = str]: ...
TD1 = A[float]
type TD2 = A[float]
def func_d1(
a: TD1,
b: TD1[float], # E: Bad number of arguments for type alias, expected 0, given 1
c: TD2,
d: TD2[float], # E: Bad number of arguments for type alias, expected 0, given 1
) -> None:
reveal_type(a) # N: Revealed type is "__main__.A[builtins.float, builtins.str]"
reveal_type(b) # N: Revealed type is "__main__.A[builtins.float, builtins.str]"
reveal_type(c) # N: Revealed type is "__main__.A[builtins.float, builtins.str]"
reveal_type(d) # N: Revealed type is "__main__.A[builtins.float, builtins.str]"
[builtins fixtures/tuple.pyi]
[typing fixtures/typing-full.pyi]
[case testTypeVarConstraintsDefaultAliasesInline]
type K = int
type V = int
class A1[T: (str, int) = K]:
x: T
class A2[T: (str, K) = K]:
x: T
class A3[T: (str, K) = V]:
x: T
reveal_type(A1().x) # N: Revealed type is "builtins.int"
reveal_type(A2().x) # N: Revealed type is "builtins.int"
reveal_type(A3().x) # N: Revealed type is "builtins.int"
[builtins fixtures/tuple.pyi]
[case testTypeVarDefaultToAnotherTypeVarClass]
class A[X, Y = X, Z = Y]:
x: X
y: Y
z: Z
a1: A[int]
reveal_type(a1.x) # N: Revealed type is "builtins.int"
reveal_type(a1.y) # N: Revealed type is "builtins.int"
reveal_type(a1.z) # N: Revealed type is "builtins.int"
a2: A[int, str]
reveal_type(a2.x) # N: Revealed type is "builtins.int"
reveal_type(a2.y) # N: Revealed type is "builtins.str"
reveal_type(a2.z) # N: Revealed type is "builtins.str"
a3: A[int, str, bool]
reveal_type(a3.x) # N: Revealed type is "builtins.int"
reveal_type(a3.y) # N: Revealed type is "builtins.str"
reveal_type(a3.z) # N: Revealed type is "builtins.bool"
[builtins fixtures/tuple.pyi]
[case testTypeVarDefaultToAnotherTypeVarAlias]
type A[X, Y = X, Z = Y] = tuple[X, Y, Z]
a1: A[int]
reveal_type(a1[0]) # N: Revealed type is "builtins.int"
reveal_type(a1[1]) # N: Revealed type is "builtins.int"
reveal_type(a1[2]) # N: Revealed type is "builtins.int"
a2: A[int, str]
reveal_type(a2[0]) # N: Revealed type is "builtins.int"
reveal_type(a2[1]) # N: Revealed type is "builtins.str"
reveal_type(a2[2]) # N: Revealed type is "builtins.str"
a3: A[int, str, bool]
reveal_type(a3[0]) # N: Revealed type is "builtins.int"
reveal_type(a3[1]) # N: Revealed type is "builtins.str"
reveal_type(a3[2]) # N: Revealed type is "builtins.bool"
[builtins fixtures/tuple.pyi]
[case testTypeVarDefaultAssertTypeType]
from typing import assert_type
class NoNonDefaults[T = str, S = int]: ...
assert_type(NoNonDefaults[()], type[NoNonDefaults[str, int]])
assert_type(NoNonDefaults[str], type[NoNonDefaults[str, int]])
assert_type(NoNonDefaults[str, int], type[NoNonDefaults[str, int]])
[builtins fixtures/tuple.pyi]
[case testTypeVarDefaultToAnotherTypeVarWrong]
class A[Y = X, X = int]: ... # E: Name "X" is not defined
class B[Y = X]: ... # E: Name "X" is not defined
[builtins fixtures/tuple.pyi]
[case testTernaryOperatorWithTypeVarDefault]
# https://github.com/python/mypy/issues/18817
class Ok[T, E = None]:
def __init__(self, value: T) -> None:
self._value = value
class Err[E, T = None]:
def __init__(self, value: E) -> None:
self._value = value
type Result[T, E] = Ok[T, E] | Err[E, T]
class Bar[U]:
def foo(data: U, cond: bool) -> Result[U, str]:
return Ok(data) if cond else Err("Error")
[case testRecursiveTypeVarDefaultBasicNewStyle]
class C[T: C = C]:
pass
c: C
reveal_type(c) # N: Revealed type is "__main__.C[__main__.C[Any]]"
[case testRecursiveTypeVarDefaultMutualNewStyle]
class C[T = D]:
pass
class D[S = C]:
pass
c: C
d: D
reveal_type(c) # N: Revealed type is "__main__.C[__main__.D[Any]]"
reveal_type(d) # N: Revealed type is "__main__.D[__main__.C[Any]]"
[case testNonRecursiveSimpleTypeVarDefaultNewStyle]
class Child[S = Parent]: ...
class Parent[T = int]: ...
reveal_type(Child()) # N: Revealed type is "__main__.Child[__main__.Parent[builtins.int]]"
[case testNonRecursiveTypeVarDefaultImportCycleClassNewStyle]
import exp
[file exp.pyi]
import ind
class F[T: D = D]:
x: T
class D(E): ...
class E: ...
[file ind.pyi]
from exp import F
class Ind(F): ...
x: Ind
reveal_type(x.x) # N: Revealed type is "exp.D"
[case testNonRecursiveTypeVarDefaultImportCycleAliasNewStyle]
import exp
[file exp.pyi]
import ind
type F[T: D = D] = list[T]
class D(E): ...
class E: ...
[file ind.pyi]
from exp import F
type Ind = list[F]
x: Ind
reveal_type(x) # N: Revealed type is "builtins.list[builtins.list[exp.D]]"
[case testRecursiveTypeVarDefaultClassAndAliasNewStyle]
class Trait[T = Pattern]:
pass
class Pattern1(Trait):
pass
class Pattern2(Trait):
pass
type Pattern = Pattern1 | Pattern2
reveal_type(Trait()) # N: Revealed type is "__main__.Trait[__main__.Pattern1 | __main__.Pattern2]"
[builtins fixtures/tuple.pyi]
[case testRecursiveTypeVarDefaultOnlyAliasNewStyle]
type A[T = A] = list[T]
a: A
reveal_type(a) # N: Revealed type is "builtins.list[builtins.list[Any]]"
[builtins fixtures/tuple.pyi]
[case testRecursiveAliasTypeVarDefaultNewStyle]
type A[T = A] = int
a: A
reveal_type(a) # N: Revealed type is "builtins.int"
[case testPEP695VariadicGenericClassEmptyTupleUnpackIndex]
class Blah[*Ts]:
pass
x: Blah[()]
y: Blah[*tuple[()]]
type Empty = tuple[()]
z: Blah[*Empty]
reveal_type(x) # N: Revealed type is "__main__.Blah[()]"
reveal_type(y) # N: Revealed type is "__main__.Blah[()]"
reveal_type(z) # N: Revealed type is "__main__.Blah[()]"
[builtins fixtures/tuple.pyi]
[case testPEP695VariadicGenericAliasEmptyTupleUnpackIndex]
type Blah[*Ts] = list[tuple[*Ts]]
x: Blah[()]
y: Blah[*tuple[()]]
type Empty = tuple[()]
z: Blah[*Empty]
reveal_type(x) # N: Revealed type is "builtins.list[tuple[()]]"
reveal_type(y) # N: Revealed type is "builtins.list[tuple[()]]"
reveal_type(z) # N: Revealed type is "builtins.list[tuple[()]]"
[builtins fixtures/tuple.pyi]
[case testPEP695InferVarianceInFrozenDataclass]
# On Python 3.13+ the dataclass plugin synthesizes a __replace__ method whose
# keyword parameters reuse the field types. Being plugin-generated, it must not
# drag the type variable into a contravariant position and make an otherwise
# covariant frozen dataclass invariant.
from dataclasses import dataclass
@dataclass(frozen=True)
class Covariant[T]:
x: T
cov1: Covariant[float] = Covariant[int](1)
cov2: Covariant[int] = Covariant[float](1) # E: Incompatible types in assignment (expression has type "Covariant[float]", variable has type "Covariant[int]")
[builtins fixtures/tuple.pyi]
[typing fixtures/typing-full.pyi]