Debian Codegraph @

test-data/unit/semanal-errors.test

raw
1 [case testUndefinedVariableInGlobalStatement]
2 import typing
3 x
4 y
5 [out]
6 main:2: error: Name "x" is not defined
7 main:3: error: Name "y" is not defined
8
9 [case testUndefinedVariableWithinFunctionContext]
10 import typing
11 def f() -> None:
12 x
13 y
14 [out]
15 main:3: error: Name "x" is not defined
16 main:4: error: Name "y" is not defined
17
18 [case testMethodScope]
19 import typing
20 class A:
21 def f(self): pass
22 f
23 [out]
24 main:4: error: Name "f" is not defined
25
26 [case testMethodScope2]
27 import typing
28 class A:
29 def f(self): pass
30 class B:
31 def g(self) -> None:
32 f # error
33 g # error
34 [out]
35 main:6: error: Name "f" is not defined
36 main:7: error: Name "g" is not defined
37
38 [case testInvalidType]
39 import typing
40 x = None # type: X
41 [out]
42 main:2: error: Name "X" is not defined
43
44 [case testInvalidGenericArg]
45 from typing import TypeVar, Generic
46 t = TypeVar('t')
47 class A(Generic[t]): pass
48 x = 0 # type: A[y]
49 [out]
50 main:4: error: Name "y" is not defined
51
52 [case testInvalidNumberOfGenericArgsInTypeDecl]
53 from typing import TypeVar, Generic
54 t = TypeVar('t')
55 class A: pass
56 class B(Generic[t]): pass
57 x = 0 # type: B[A, A]
58 y = 0 # type: A[A]
59 [out]
60 main:5: error: "B" expects 1 type argument, but 2 given
61 main:6: error: "A" expects no type arguments, but 1 given
62
63 [case testInvalidNumberOfGenericArgsInUndefinedArg]
64
65 class A: pass
66 x = None # type: A[int] # E: "A" expects no type arguments, but 1 given
67 [out]
68
69 [case testInvalidNumberOfGenericArgsInNestedBlock]
70
71 class A: pass
72 class B:
73 def f(self) -> None:
74 while 1:
75 x = None # type: A[int] \
76 # E: "A" expects no type arguments, but 1 given
77 [out]
78
79 [case testInvalidNumberOfGenericArgsInSignature]
80 import typing
81 class A: pass
82 def f() -> A[int]: pass # E: "A" expects no type arguments, but 1 given
83 [out]
84
85 [case testInvalidNumberOfGenericArgsInOverloadedSignature]
86 from typing import overload
87 class A: pass
88 @overload
89 def f(): pass
90 @overload
91 def f(x: A[int]) -> None: pass # E: "A" expects no type arguments, but 1 given
92 def f(*args): pass
93 [out]
94
95 [case testInvalidNumberOfGenericArgsInBaseType]
96 import typing
97 class A: pass
98 class B(A[int]): pass # E: "A" expects no type arguments, but 1 given
99 [out]
100
101 [case testInvalidNumberOfGenericArgsInCast]
102 from typing import cast
103 class A: pass
104 x = cast(A[int], 1) # E: "A" expects no type arguments, but 1 given
105 [out]
106
107 [case testInvalidNumberOfGenericArgsInNestedGenericType]
108 from typing import TypeVar, Generic
109 T = TypeVar('T')
110 class A(Generic[T]): pass
111 class B: pass
112 def f() -> A[B[int]]: pass # E: "B" expects no type arguments, but 1 given
113 [out]
114
115 [case testInvalidNumberOfGenericArgsInTupleType]
116 from typing import Tuple
117 class A: pass
118 x = None # type: Tuple[A[int]] # E: "A" expects no type arguments, but 1 given
119 [builtins fixtures/tuple.pyi]
120 [out]
121
122 [case testInvalidNumberOfGenericArgsInFunctionType]
123 from typing import Callable
124 class A: pass
125 x = None # type: Callable[[A[int]], int] # E: "A" expects no type arguments, but 1 given
126 y = None # type: Callable[[], A[int]] # E: "A" expects no type arguments, but 1 given
127 [out]
128
129 [case testVarOrFuncAsType]
130
131 import typing
132 def f(): pass
133 x = 1
134 y = 0 # type: f
135 z = 0 # type: x
136 [out]
137 main:5: error: Function "__main__.f" is not valid as a type
138 main:5: note: Perhaps you need "Callable[...]" or a callback protocol?
139 main:6: error: Variable "__main__.x" is not valid as a type
140 main:6: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
141
142 [case testGlobalVarRedefinition]
143 import typing
144 class A: pass
145 x = 0 # type: A
146 x = 0 # type: A
147 [out]
148 main:4: error: Name "x" already defined on line 3
149
150 [case testLocalVarRedefinition]
151 import typing
152 class A: pass
153 def f() -> None:
154 x = 0 # type: A
155 x = 0 # type: A
156 [out]
157 main:5: error: Name "x" already defined on line 4
158
159 [case testClassVarRedefinition]
160 import typing
161 class A:
162 x = 0 # type: object
163 x = 0 # type: object
164 [out]
165 main:4: error: Name "x" already defined on line 3
166
167 [case testMultipleClassDefinitions]
168 import typing
169 class A: pass
170 class A: pass
171 [out]
172 main:3: error: Name "A" already defined on line 2
173
174 [case testMultipleMixedDefinitions]
175 import typing
176 x = 1
177 def x(): pass
178 class x: pass
179 [out]
180 main:3: error: Name "x" already defined on line 2
181 main:4: error: Name "x" already defined on line 2
182
183 [case testNameNotImported]
184 import typing
185 from m import y
186 x
187 [file m.py]
188 x = y = 1
189 [out]
190 main:3: error: Name "x" is not defined
191
192 [case testMissingNameInImportFrom]
193 import typing
194 from m import y
195 [file m.py]
196 x = 1
197 [out]
198 main:2: error: Module "m" has no attribute "y"
199
200 [case testMissingModule]
201 import typing
202 import m
203 [out]
204 main:2: error: Cannot find implementation or library stub for module named "m"
205 main:2: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
206
207 [case testMissingModule2]
208 import typing
209 from m import x
210 [out]
211 main:2: error: Cannot find implementation or library stub for module named "m"
212 main:2: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
213
214 [case testMissingModule3]
215 import typing
216 from m import *
217 [out]
218 main:2: error: Cannot find implementation or library stub for module named "m"
219 main:2: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
220
221 [case testMissingModuleRelativeImport]
222 import typing
223 import m
224 [file m/__init__.py]
225 from .x import y
226 [out]
227 tmp/m/__init__.py:1: error: Cannot find implementation or library stub for module named "m.x"
228 tmp/m/__init__.py:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
229
230 [case testMissingModuleRelativeImport2]
231 import typing
232 import m.a
233 [file m/__init__.py]
234 [file m/a.py]
235 from .x import y
236 [out]
237 tmp/m/a.py:1: error: Cannot find implementation or library stub for module named "m.x"
238 tmp/m/a.py:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
239
240 [case testModuleNotImported]
241 import typing
242 import _m
243 _n.x
244 [file _m.py]
245 import _n
246 [file _n.py]
247 x = 1
248 [out]
249 main:3: error: Name "_n" is not defined
250
251 [case testImportAsteriskPlusUnderscore]
252 import typing
253 from _m import *
254 _x
255 __x__
256 [file _m.py]
257 _x = __x__ = 1
258 [out]
259 main:3: error: Name "_x" is not defined
260 main:4: error: Name "__x__" is not defined
261
262 [case testRelativeImportAtTopLevelModule]
263 from . import m
264 [out]
265 main:1: error: No parent module -- cannot perform relative import
266
267 [case testRelativeImportAtTopLevelModule2]
268 from .. import m
269 [out]
270 main:1: error: No parent module -- cannot perform relative import
271
272 [case testUndefinedTypeWithQualifiedName]
273 import typing
274 import m
275 def f() -> m.c: pass
276 def g() -> n.c: pass
277 [file m.py]
278 [out]
279 main:3: error: Name "m.c" is not defined
280 main:4: error: Name "n" is not defined
281
282 [case testMissingPackage]
283 import typing
284 import m.n
285 [out]
286 main:2: error: Cannot find implementation or library stub for module named "m.n"
287 main:2: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
288 main:2: error: Cannot find implementation or library stub for module named "m"
289
290 [case testMissingPackage2]
291 import typing
292 from m.n import x
293 from a.b import *
294 [out]
295 main:2: error: Cannot find implementation or library stub for module named "m.n"
296 main:2: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
297 main:3: error: Cannot find implementation or library stub for module named "a.b"
298
299 [case testMissingModuleFuzzyMatchThirdParty]
300 import numpyy
301 [out]
302 main:1: error: Cannot find implementation or library stub for module named "numpyy"
303 main:1: note: Did you mean "numpy"?
304 main:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
305
306 [case testMissingModuleFuzzyMatchFromImport]
307 from numpyy import array
308 [out]
309 main:1: error: Cannot find implementation or library stub for module named "numpyy"
310 main:1: note: Did you mean "numpy"?
311 main:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
312
313 [case testMissingModuleFuzzyMatchStdlib]
314 import ittertools
315 [out]
316 main:1: error: Cannot find implementation or library stub for module named "ittertools"
317 main:1: note: Did you mean "itertools"?
318 main:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
319
320 [case testMissingModuleFuzzyMatchNoSuggestion]
321 import xyzabc123
322 [out]
323 main:1: error: Cannot find implementation or library stub for module named "xyzabc123"
324 main:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
325
326 [case testMissingModuleFuzzyMatchUnderscorePrefix]
327 import _pytest.fixtures
328 [out]
329 main:1: error: Cannot find implementation or library stub for module named "_pytest.fixtures"
330 main:1: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
331
332 [case testMissingModuleFuzzyMatchTypeIgnore]
333 import numpyy # type: ignore
334 [out]
335
336 [case testErrorInImportedModule]
337 import m
338 [file m.py]
339 import typing
340 x = y
341 [out]
342 tmp/m.py:2: error: Name "y" is not defined
343
344 [case testErrorInImportedModule2]
345 import m.n
346 [file m/__init__.py]
347 [file m/n.py]
348 import k
349 [file k.py]
350 import typing
351 x = y
352 [out]
353 tmp/k.py:2: error: Name "y" is not defined
354
355 [case testPackageWithoutInitFile]
356 # flags: --no-namespace-packages
357 import typing
358 import m.n
359 m.n.x
360 [file m/n.py]
361 x = 1
362 [out]
363 main:3: error: Cannot find implementation or library stub for module named "m.n"
364 main:3: note: See https://mypy.readthedocs.io/en/stable/running_mypy.html#missing-imports
365 main:3: error: Cannot find implementation or library stub for module named "m"
366
367 [case testBreakOutsideLoop]
368 break
369 def f():
370 break
371 [out]
372 main:1: error: "break" outside loop
373 main:3: error: "break" outside loop
374
375 [case testContinueOutsideLoop]
376 continue
377 def f():
378 continue
379 [out]
380 main:1: error: "continue" outside loop
381 main:3: error: "continue" outside loop
382
383 [case testReturnOutsideFunction]
384 def f(): pass
385 return
386 return 1
387 [out]
388 main:2: error: "return" outside function
389 main:3: error: "return" outside function
390
391 [case testYieldOutsideFunction]
392 yield 1
393 yield
394 [out]
395 main:1: error: "yield" outside function
396 main:2: error: "yield" outside function
397
398 [case testInvalidLvalues1]
399 1 = 1
400 [out]
401 main:1: error: Cannot assign to literal here. Maybe you meant '==' instead of '='?
402
403 [case testInvalidLvalues2]
404 (1) = 1
405 [out]
406 main:1: error: Cannot assign to literal here. Maybe you meant '==' instead of '='?
407
408 [case testInvalidLvalues3]
409 (1, 1) = 1
410 [out]
411 main:1: error: Cannot assign to literal
412
413 [case testInvalidLvalues4]
414 [1, 1] = 1
415 [out]
416 main:1: error: Cannot assign to literal
417
418 [case testInvalidLvalues6]
419 x = y = z = 1 # ok
420 x, (y, 1) = 1
421 [out]
422 main:2: error: Cannot assign to literal
423
424 [case testInvalidLvalues7]
425 x, [y, 1] = 1
426 [out]
427 main:1: error: Cannot assign to literal
428
429 [case testInvalidLvalues8]
430 x, [y, [z, 1]] = 1
431 [out]
432 main:1: error: Cannot assign to literal
433
434 [case testInvalidLvalues9]
435 x, (y) = 1 # ok
436 x, (y, (z, z)) = 1 # ok
437 x, (y, (z, 1)) = 1
438 [out]
439 main:3: error: Cannot assign to literal
440
441 [case testInvalidLvalues10]
442 x + x = 1
443 [out]
444 main:1: error: Cannot assign to expression here. Maybe you meant '==' instead of '='?
445
446 [case testInvalidLvalues11]
447 -x = 1
448 [out]
449 main:1: error: Cannot assign to expression here. Maybe you meant '==' instead of '='?
450
451 [case testInvalidLvalues12]
452 1.1 = 1
453 [out]
454 main:1: error: Cannot assign to literal here. Maybe you meant '==' instead of '='?
455
456 [case testInvalidLvalues13]
457 'x' = 1
458 [out]
459 main:1: error: Cannot assign to literal here. Maybe you meant '==' instead of '='?
460
461 [case testInvalidLvalues14]
462 x() = 1
463 [out]
464 main:1: error: Cannot assign to function call here. Maybe you meant '==' instead of '='?
465
466 [case testTwoStarExpressions]
467 a, *b, *c = 1
468 *a, (*b, c) = 1
469 a, (*b, *c) = 1
470 [*a, *b] = 1
471 [out]
472 main:1: error: Two starred expressions in assignment
473 main:3: error: Two starred expressions in assignment
474 main:4: error: Two starred expressions in assignment
475
476 [case testTwoStarExpressionsInForStmt]
477 z = 1
478 for a, *b, *c in z:
479 pass
480 for *a, (*b, c) in z:
481 pass
482 for a, (*b, *c) in z:
483 pass
484 for [*a, *b] in z:
485 pass
486 [out]
487 main:2: error: Two starred expressions in assignment
488 main:6: error: Two starred expressions in assignment
489 main:8: error: Two starred expressions in assignment
490
491 [case testTwoStarExpressionsInGeneratorExpr]
492 (a for a, *b, *c in [])
493 (a for *a, (*b, c) in [])
494 (a for a, (*b, *c) in [])
495 [out]
496 main:1: error: Name "a" is not defined
497 main:1: error: Two starred expressions in assignment
498 main:3: error: Two starred expressions in assignment
499
500 [case testStarExpressionRhs]
501 b = 1
502 c = 1
503 d = 1
504 a = *b
505 [out]
506 main:4: error: can't use starred expression here
507
508 [case testStarExpressionInExp]
509 a = 1
510 *a + 1
511 [out]
512 main:2: error: can't use starred expression here
513
514 [case testInvalidDel1]
515 x = 1
516 del x(1)
517 [out]
518 main:2: error: Cannot delete function call
519
520 [case testInvalidDel2]
521 x = 1
522 del x + 1
523 [out]
524 main:2: error: Cannot delete expression
525
526 [case testInvalidDel3]
527 del z # E: Name "z" is not defined
528
529 [case testFunctionTvarScope]
530
531 from typing import TypeVar
532 t = TypeVar('t')
533 def f(x: t) -> t: pass
534 x = 0 # type: t
535 [out]
536 main:5: error: Type variable "__main__.t" is unbound
537 main:5: note: (Hint: Use "Generic[t]" or "Protocol[t]" base class to bind "t" inside a class)
538 main:5: note: (Hint: Use "t" in function signature to bind "t" inside a function)
539
540 [case testClassTvarScope]
541
542 from typing import Generic, TypeVar
543 t = TypeVar('t')
544 class c(Generic[t]): pass
545 x = 0 # type: t
546 [out]
547 main:5: error: Type variable "__main__.t" is unbound
548 main:5: note: (Hint: Use "Generic[t]" or "Protocol[t]" base class to bind "t" inside a class)
549 main:5: note: (Hint: Use "t" in function signature to bind "t" inside a function)
550
551 [case testExpressionRefersToTypeVariable]
552 from typing import TypeVar, Generic
553 t = TypeVar('t')
554 class c(Generic[t]):
555 def f(self) -> None: x = t
556 def f(y: t): x = t
557 [out]
558 main:4: error: "t" is a type variable and only valid in type context
559 main:5: error: "t" is a type variable and only valid in type context
560
561 [case testInvalidBaseClass]
562 import typing
563 class A(B): pass
564 [out]
565 main:2: error: Name "B" is not defined
566
567 [case testSuperOutsideClass]
568 class A: pass
569 super().x
570 def f() -> None: super().y
571 [out]
572 main:2: error: "super" used outside class
573 main:3: error: "super" used outside class
574
575 [case testMultipleMethodDefinition]
576 import typing
577 class A:
578 def f(self) -> None: pass
579 def g(self) -> None: pass
580 def f(self, x: object) -> None: pass
581 [out]
582 main:5: error: Name "f" already defined on line 3
583
584 [case testInvalidGlobalDecl]
585 import typing
586 def f() -> None:
587 global x
588 x = None
589 [out]
590 main:4: error: Name "x" is not defined
591
592 [case testInvalidNonlocalDecl]
593 import typing
594 def f():
595 def g() -> None:
596 nonlocal x
597 x = None
598 [out]
599 main:4: error: No binding for nonlocal "x" found
600 main:5: error: Name "x" is not defined
601
602 [case testNonlocalDeclNotMatchingGlobal]
603 import typing
604 x = None
605 def f() -> None:
606 nonlocal x
607 x = None
608 [out]
609 main:4: error: No binding for nonlocal "x" found
610 main:5: error: Name "x" is not defined
611
612 [case testNonlocalDeclConflictingWithParameter]
613 import typing
614 def g():
615 x = None
616 def f(x) -> None:
617 nonlocal x
618 x = None
619 [out]
620 main:5: error: Name "x" is already defined in local scope before nonlocal declaration
621
622 [case testNonlocalDeclOutsideFunction]
623 x = 2
624 nonlocal x
625 [out]
626 main:2: error: nonlocal declaration not allowed at module level
627
628 [case testGlobalAndNonlocalDecl]
629 import typing
630 x = 1
631 def f():
632 x = 1
633 def g() -> None:
634 global x
635 nonlocal x
636 x = None
637 [out]
638 main:7: error: Name "x" is nonlocal and global
639
640 [case testNonlocalAndGlobalDecl]
641 import typing
642 x = 1
643 def f():
644 x = 1
645 def g() -> None:
646 nonlocal x
647 global x
648 x = None
649 [out]
650 main:7: error: Name "x" is nonlocal and global
651
652 [case testNestedFunctionAndScoping]
653 import typing
654 def f(x) -> None:
655 def g(y):
656 z = x
657 z
658 y
659 x
660 [out]
661 main:5: error: Name "z" is not defined
662 main:6: error: Name "y" is not defined
663
664 [case testMultipleNestedFunctionDef]
665 import typing
666 def f(x) -> None:
667 def g(): pass
668 x = 1
669 def g(): pass
670 [out]
671 main:5: error: Name "g" already defined on line 3
672
673 [case testRedefinedOverloadedFunction]
674 from typing import overload, Any
675 def f() -> None:
676 @overload
677 def p(o: object) -> None: pass # no error
678 @overload
679 def p(o: Any) -> None: pass # no error
680 x = 1
681 def p(): pass # fail
682 [out]
683 main:3: error: An overloaded function outside a stub file must have an implementation
684 main:8: error: Name "p" already defined on line 3
685
686 [case testNestedFunctionInMethod]
687 import typing
688 class A:
689 def f(self) -> None:
690 def g() -> None:
691 x
692 y
693 [out]
694 main:5: error: Name "x" is not defined
695 main:6: error: Name "y" is not defined
696
697 [case testImportScope]
698 import typing
699 def f() -> None:
700 import x
701 x.y # E: Name "x" is not defined
702 [file x.py]
703 y = 1
704 [out]
705
706 [case testImportScope2]
707 import typing
708 def f() -> None:
709 from x import y
710 y
711 y # E: Name "y" is not defined
712 [file x.py]
713 y = 1
714 [out]
715
716 [case testImportScope3]
717 import typing
718 def f() -> None:
719 from x import *
720 y
721 y # E: Name "y" is not defined
722 [file x.py]
723 y = 1
724 [out]
725
726 [case testImportScope4]
727 import typing
728 class A:
729 from x import *
730 y
731 y # E: Name "y" is not defined
732 [file x.py]
733 y = 1
734 [out]
735
736 [case testScopeOfNestedClass]
737 import typing
738 def f():
739 class A: pass
740 A
741 A # E: Name "A" is not defined
742 [out]
743
744 [case testScopeOfNestedClass2]
745 import typing
746 class A:
747 class B: pass
748 B # E: Name "B" is not defined
749 [out]
750
751 [case testScopeOfNestedClass3]
752 import typing
753 class A:
754 def f(self):
755 class B: pass
756 B # E: Name "B" is not defined
757 B # E: Name "B" is not defined
758 [out]
759
760 [case testInvalidNestedClassReferenceInDecl]
761 import typing
762 class A: pass
763 foo = 0 # type: A.x # E: Name "A.x" is not defined
764 [out]
765
766 [case testTvarScopingWithNestedClass]
767
768 from typing import TypeVar, Generic
769 t = TypeVar('t')
770 s = TypeVar('s')
771 class A(Generic[t]):
772 class B(Generic[s]):
773 x = 0 # type: A[s]
774 y = 0 # type: A[t] # E: Type variable "__main__.t" is unbound \
775 # N: (Hint: Use "Generic[t]" or "Protocol[t]" base class to bind "t" inside a class) \
776 # N: (Hint: Use "t" in function signature to bind "t" inside a function)
777 z = 0 # type: A[s] # E: Type variable "__main__.s" is unbound \
778 # N: (Hint: Use "Generic[s]" or "Protocol[s]" base class to bind "s" inside a class) \
779 # N: (Hint: Use "s" in function signature to bind "s" inside a function)
780 a = 0 # type: A[t]
781 [out]
782
783 [case testTestExtendPrimitives]
784 # Extending bool is not checked here as it should be typed
785 # as final meaning the type checker will detect it.
786 class C(bool): pass # ok
787 class A(int): pass # ok
788 class B(float): pass # ok
789 class D(str): pass # ok
790 [builtins fixtures/primitives.pyi]
791 [out]
792
793 [case testCyclicInheritance1]
794
795 class A(A): pass # E: Cannot resolve name "A" (possible cyclic definition)
796 [out]
797
798 [case testCyclicInheritance2]
799
800 class A(B): pass # E: Cannot resolve name "B" (possible cyclic definition)
801 class B(A): pass
802 [out]
803
804 [case testAssignToTypeDef]
805 import typing
806 class A: pass
807 A = None # E: Cannot assign to a type
808 [out]
809
810 [case testInvalidCastTargetSyntax]
811
812 from typing import cast, TypeVar, Generic
813 t = TypeVar('t')
814 class C(Generic[t]): pass
815 cast(str + str, None) # E: Cast target is not a type
816 cast(C[str][str], None) # E: Cast target is not a type
817 cast(C[str + str], None) # E: Cast target is not a type
818 cast([int], None) # E: Bracketed expression "[...]" is not valid as a type \
819 # N: Did you mean "List[...]"?
820 [out]
821
822 [case testInvalidCastTargetType]
823
824 from typing import cast
825 x = 0
826 cast(x, None) # E: Variable "__main__.x" is not valid as a type \
827 # N: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
828 cast(t, None) # E: Name "t" is not defined
829 cast(__builtins__.x, None) # E: Name "__builtins__.x" is not defined
830 [out]
831
832 [case testInvalidCastTargetType2]
833 from typing import cast
834 x = 0
835 cast(str[str], None) # E: "str" expects no type arguments, but 1 given
836 [out]
837
838 [case testInvalidNumberOfArgsToCast]
839 from typing import cast
840 cast(str) # E: "cast" expects 2 arguments
841 cast(str, None, None) # E: "cast" expects 2 arguments
842 [out]
843
844 [case testInvalidKindsOfArgsToCast]
845 from typing import cast
846 cast(str, *None) # E: "cast" must be called with 2 positional arguments
847 cast(str, target=None) # E: "cast" must be called with 2 positional arguments
848 [out]
849
850 [case testInvalidAssertType]
851 from typing import assert_type
852 assert_type(1, type=int) # E: "assert_type" must be called with 2 positional arguments
853 assert_type(1, *int) # E: "assert_type" must be called with 2 positional arguments
854 assert_type() # E: "assert_type" expects 2 arguments
855 assert_type(1, int, "hello") # E: "assert_type" expects 2 arguments
856 assert_type(int, 1) # E: Invalid type: try using Literal[1] instead?
857 assert_type(1, int[int]) # E: "int" expects no type arguments, but 1 given
858
859 [case testInvalidAnyCall]
860 from typing import Any
861 Any(str, None) # E: Any(...) is no longer supported. Use cast(Any, ...) instead
862 Any(arg=str) # E: Any(...) is no longer supported. Use cast(Any, ...) instead
863 [out]
864
865 [case testTypeListAsType]
866
867 def f(x: [int]) -> None: # E: Bracketed expression "[...]" is not valid as a type \
868 # N: Did you mean "List[...]"?
869 pass
870 [out]
871
872 [case testInvalidFunctionType]
873 from typing import Callable
874 x = None # type: Callable[int, str]
875 y = None # type: Callable[int]
876 z = None # type: Callable[int, int, int]
877 [out]
878 main:2: error: The first argument to Callable must be a list of types, parameter specification, or "..."
879 main:2: note: See https://mypy.readthedocs.io/en/stable/kinds_of_types.html#callable-types-and-lambdas
880 main:3: error: Please use "Callable[[<parameters>], <return type>]" or "Callable"
881 main:4: error: Please use "Callable[[<parameters>], <return type>]" or "Callable"
882
883 [case testAbstractGlobalFunction]
884 import typing
885 from abc import abstractmethod
886 @abstractmethod
887 def foo(): pass
888 [out]
889 main:3: error: "abstractmethod" used with a non-method
890
891 [case testAbstractNestedFunction]
892 import typing
893 from abc import abstractmethod
894 def g() -> None:
895 @abstractmethod
896 def foo(): pass
897 [out]
898 main:4: error: "abstractmethod" used with a non-method
899
900 [case testInvalidTypeDeclaration]
901 import typing
902 def f(): pass
903 f() = 1 # type: int
904 [out]
905 main:3: error: Cannot assign to function call here. Maybe you meant '==' instead of '='?
906
907 [case testIndexedAssignmentWithTypeDeclaration]
908 import typing
909 None[1] = 1 # type: int
910 [out]
911 main:2: error: Unexpected type declaration
912
913 [case testNonSelfMemberAssignmentWithTypeDeclaration]
914 import typing
915 None.x = 1 # type: int
916 [out]
917 main:2: error: Type cannot be declared in assignment to non-self attribute
918
919 [case testNonSelfMemberAssignmentWithTypeDeclarationInMethod]
920 import typing
921 class A:
922 def f(self, x) -> None:
923 x.y = 1 # type: int
924 [out]
925 main:4: error: Type cannot be declared in assignment to non-self attribute
926
927 [case testInvalidTypeInTypeApplication]
928
929 from typing import TypeVar, Generic
930 t = TypeVar('t')
931 class A(Generic[t]): pass
932 A[TypeVar] # E: Variable "typing.TypeVar" is not valid as a type \
933 # N: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
934 [out]
935
936 [case testInvalidTypeInTypeApplication2]
937 from typing import TypeVar, Generic
938 t = TypeVar('t')
939 class A(Generic[t]): pass
940 A[1] # E: Invalid type: try using Literal[1] instead?
941 [out]
942
943 [case testVariableDeclWithInvalidNumberOfTypes]
944 x, y = 1, 2 # type: int, str, int # E: Incompatible number of tuple items
945 [builtins fixtures/tuple.pyi]
946 [out]
947
948 [case testVariableDeclWithInvalidNumberOfTypesNested]
949 x, (y, z) = 1, (2, 3) # type: int, (str, int, int) # E: Incompatible number of tuple items
950 [builtins fixtures/tuple.pyi]
951 [out]
952
953 [case testVariableDeclWithInvalidNumberOfTypesNested2]
954 x, (y, z) = 1, (2, 3) # type: int, (str, ) # E: Incompatible number of tuple items
955 [builtins fixtures/tuple.pyi]
956 [out]
957
958 [case testVariableDeclWithInvalidNumberOfTypesNested3]
959 x, (y, z) = 1, (2, 3) # type: int, str # E: Tuple type expected for multiple variables
960 [builtins fixtures/tuple.pyi]
961 [out]
962
963 [case testVariableDeclWithInvalidNumberOfTypesNested4]
964 x, (y, z) = 1, (2, 3) # type: int, str, int # E: Incompatible number of tuple items
965 [builtins fixtures/tuple.pyi]
966 [out]
967
968 [case testVariableDeclWithInvalidNumberOfTypesNested5]
969 x, (y, ) = 1, (2, ) # type: int, str # E: Tuple type expected for multiple variables
970 [builtins fixtures/tuple.pyi]
971 [out]
972
973 [case testVariableDeclWithInvalidType]
974 x, y = 1, 2 # type: int # E: Tuple type expected for multiple variables
975 [out]
976
977 [case testInvalidLvalueWithExplicitType]
978 a = 1
979 a() = None # type: int
980 [out]
981 main:2: error: Cannot assign to function call here. Maybe you meant '==' instead of '='?
982
983 [case testInvalidLvalueWithExplicitType2]
984 a = 1
985 a[1] = None # type: int # E: Unexpected type declaration
986 a.x = None # type: int \
987 # E: Type cannot be declared in assignment to non-self attribute
988 [out]
989
990 [case testInvalidLvalueWithExplicitType3]
991 a = 1
992 a.y, a.x = None, None # type: int, int \
993 # E: Type cannot be declared in assignment to non-self attribute
994 a[1], a[2] = None, None # type: int, int \
995 # E: Unexpected type declaration
996 [builtins fixtures/tuple.pyi]
997 [out]
998
999 [case testMissingGenericImport]
1000 from typing import TypeVar
1001 T = TypeVar('T')
1002 class A(Generic[T]): pass
1003 [out]
1004 main:3: error: Name "Generic" is not defined
1005
1006 [case testInvalidTypeWithinGeneric]
1007 from typing import Generic
1008 class A(Generic[int]): pass # E: Free type variable expected in Generic[...]
1009 [out]
1010
1011 [case testInvalidTypeWithinNestedGenericClass]
1012 from typing import Generic, TypeVar
1013 T = TypeVar('T')
1014 class A(Generic[T]):
1015 class B(Generic[T]): pass \
1016 # E: Free type variable expected in Generic[...]
1017 [out]
1018
1019 [case testRedeclaredTypeVarWithinNestedGenericClass]
1020 from typing import Generic, Iterable, TypeVar
1021 T = TypeVar('T')
1022 class A(Generic[T]):
1023 class B(Iterable[T]): pass # E: Type variable "T" is bound by an outer class
1024
1025 [case testIncludingGenericTwiceInBaseClassList]
1026 from typing import Generic, TypeVar
1027 T = TypeVar('T')
1028 S = TypeVar('S')
1029 class A(Generic[T], Generic[S]): pass \
1030 # E: Only single Generic[...] or Protocol[...] can be in bases
1031 [out]
1032
1033 [case testInvalidMetaclass]
1034 class A(metaclass=x): pass # E: Name "x" is not defined
1035 [out]
1036
1037 [case testInvalidQualifiedMetaclass]
1038 import abc
1039 class A(metaclass=abc.Foo): pass # E: Name "abc.Foo" is not defined
1040 [out]
1041
1042 [case testNonClassMetaclass]
1043 def f(): pass
1044 class A(metaclass=f): pass # E: Invalid metaclass "f"
1045 [out]
1046
1047 [case testInvalidTypevarArguments]
1048 from typing import TypeVar
1049 a = TypeVar() # E: Too few arguments for TypeVar()
1050 b = TypeVar(x='b') # E: TypeVar() expects a string literal as first argument
1051 c = TypeVar(1) # E: TypeVar() expects a string literal as first argument
1052 T = TypeVar(b'T') # E: TypeVar() expects a string literal as first argument
1053 d = TypeVar('D') # E: String argument 1 "D" to TypeVar(...) does not match variable name "d"
1054 e = TypeVar('e', int, str, x=1) # E: Unexpected argument to "TypeVar()": "x"
1055 f = TypeVar('f', (int, str), int) # E: Type expected
1056 g = TypeVar('g', int) # E: Type variable must have at least two constrained types
1057 h = TypeVar('h', x=(int, str)) # E: Unexpected argument to "TypeVar()": "x"
1058 i = TypeVar('i', bound=1) # E: TypeVar "bound" must be a type
1059 j = TypeVar('j', covariant=None) # E: TypeVar "covariant" may only be a literal bool
1060 k = TypeVar('k', contravariant=1) # E: TypeVar "contravariant" may only be a literal bool
1061 [out]
1062
1063 [case testMoreInvalidTypevarArguments]
1064 from typing import TypeVar
1065 T = TypeVar('T', int, str, bound=bool) # E: TypeVar cannot have both values and an upper bound
1066 S = TypeVar('S', covariant=True, contravariant=True) \
1067 # E: TypeVar cannot be both covariant and contravariant
1068 [builtins fixtures/bool.pyi]
1069
1070 [case testInvalidTypevarArgumentsGenericConstraint]
1071 from typing import Generic, List, TypeVar
1072 from typing_extensions import Self
1073
1074 T = TypeVar("T")
1075
1076 def f(x: T) -> None:
1077 Bad = TypeVar("Bad", int, List[T]) # E: TypeVar constraint type cannot be parametrized by type variables
1078 class C(Generic[T]):
1079 Bad = TypeVar("Bad", int, List[T]) # E: TypeVar constraint type cannot be parametrized by type variables
1080 class D:
1081 Bad = TypeVar("Bad", int, List[Self]) # E: TypeVar constraint type cannot be parametrized by type variables
1082 S = TypeVar("S", int, List[T]) # E: Type variable "__main__.T" is unbound \
1083 # N: (Hint: Use "Generic[T]" or "Protocol[T]" base class to bind "T" inside a class) \
1084 # N: (Hint: Use "T" in function signature to bind "T" inside a function)
1085
1086 [case testInvalidTypevarValues]
1087 from typing import TypeVar
1088 b = TypeVar('b', *[int]) # E: Unexpected argument to "TypeVar()"
1089 c = TypeVar('c', int, 2) # E: Invalid type: try using Literal[2] instead?
1090 [out]
1091
1092 [case testObsoleteTypevarValuesSyntax]
1093 from typing import TypeVar
1094 a = TypeVar('a', values=(int, str))
1095 [out]
1096 main:2: error: TypeVar "values" argument not supported
1097 main:2: error: Use TypeVar('T', t, ...) instead of TypeVar('T', values=(t, ...))
1098
1099 [case testLocalTypevarScope]
1100 from typing import TypeVar
1101 def f() -> None:
1102 T = TypeVar('T')
1103 def g(x: T) -> None: pass # E: Name "T" is not defined
1104 [out]
1105
1106 [case testClassTypevarScope]
1107 from typing import TypeVar
1108 class A:
1109 T = TypeVar('T')
1110 def g(x: T) -> None: pass # E: Name "T" is not defined
1111 [out]
1112
1113 [case testRedefineVariableAsTypevar]
1114 from typing import TypeVar
1115 x = 0
1116 x = TypeVar('x') # E: Cannot redefine "x" as a type variable
1117 [out]
1118
1119 [case testTypevarWithType]
1120 from typing import TypeVar
1121 x = TypeVar('x') # type: int # E: Cannot declare the type of a TypeVar or similar construct
1122 [out]
1123
1124 [case testRedefineTypevar]
1125 from typing import TypeVar
1126 t = TypeVar('t')
1127 t = 1 # E: Invalid assignment target
1128 [out]
1129
1130 [case testRedefineTypevar2]
1131 from typing import TypeVar
1132 t = TypeVar('t')
1133 def t(): pass # E: Name "t" already defined on line 2
1134 [out]
1135
1136 [case testRedefineTypevar3]
1137 from typing import TypeVar
1138 t = TypeVar('t')
1139 class t: pass # E: Name "t" already defined on line 2
1140 [out]
1141
1142 [case testRedefineTypevar4]
1143 from typing import TypeVar
1144 t = TypeVar('t')
1145 from typing import Generic as t # E: Name "t" already defined on line 2
1146 [out]
1147
1148 [case testInvalidStrLiteralType]
1149 def f(x: 'foo'): pass # E: Name "foo" is not defined
1150 [out]
1151
1152 [case testInvalidStrLiteralStrayBrace]
1153 def f(x: 'int['): pass # E: Invalid type comment or annotation
1154 [out]
1155
1156 [case testInvalidStrLiteralSpaces]
1157 def f(x: 'A B'): pass # E: Invalid type comment or annotation
1158 [out]
1159
1160 [case testInvalidMultilineLiteralType]
1161 def f() -> "A\nB": pass # E: Invalid type comment or annotation
1162 [out]
1163
1164 [case testInconsistentOverload]
1165 from typing import overload
1166 def dec(x): pass
1167 @dec # E: The implementation for an overloaded function must come last
1168 def f(): pass
1169 @overload
1170 def f(): pass
1171 [out]
1172
1173 [case testInconsistentOverload2]
1174 from typing import overload
1175 def dec(x): pass
1176 @dec # E: The implementation for an overloaded function must come last
1177 def f(): pass
1178 @overload
1179 def f(): pass
1180 [out]
1181
1182 [case testMissingOverloadDecorator]
1183 from typing import overload
1184 def dec(x): pass
1185 @dec
1186 def f(): pass
1187 @dec # E: Name "f" already defined on line 3
1188 def f(): pass
1189 [out]
1190
1191 [case testIncompatibleSignatureInComment]
1192 import typing
1193 def f(): # type: (int) -> int
1194 pass
1195 def g(x): # type: () -> int
1196 pass
1197 [out]
1198 main:2: error: Type signature has too many parameters
1199 main:4: error: Type signature has too few parameters
1200
1201 [case testStaticmethodAndNonMethod]
1202 import typing
1203 @staticmethod
1204 def f(): pass
1205 class A:
1206 def g(self) -> None:
1207 @staticmethod
1208 def h(): pass
1209 [builtins fixtures/staticmethod.pyi]
1210 [out]
1211 main:2: error: "staticmethod" used with a non-method
1212 main:6: error: "staticmethod" used with a non-method
1213
1214 [case testClassmethodAndNonMethod]
1215 import typing
1216 @classmethod
1217 def f(): pass
1218 class A:
1219 def g(self) -> None:
1220 @classmethod
1221 def h(): pass
1222 [builtins fixtures/classmethod.pyi]
1223 [out]
1224 main:2: error: "classmethod" used with a non-method
1225 main:6: error: "classmethod" used with a non-method
1226
1227 [case testNonMethodProperty]
1228 import typing
1229 @property # E: "property" used with a non-method
1230 def f() -> int: pass
1231 [builtins fixtures/property.pyi]
1232 [out]
1233
1234 [case testOverloadedProperty]
1235 from typing import overload
1236 class A:
1237 @overload # E: Decorators on top of @property are not supported
1238 @property
1239 def f(self) -> int: pass
1240 @property # E: Only supported top decorators are "@f.setter" and "@f.deleter"
1241 @overload
1242 def f(self) -> int: pass
1243 [builtins fixtures/property.pyi]
1244 [out]
1245
1246 [case testOverloadedProperty2]
1247 from typing import overload
1248 class A:
1249 @overload # E: An overloaded function outside a stub file must have an implementation
1250 def f(self) -> int: pass
1251 @property # E: An overload can not be a property
1252 @overload
1253 def f(self) -> int: pass
1254 [builtins fixtures/property.pyi]
1255 [out]
1256
1257 [case testDecoratedProperty]
1258 import typing
1259 def dec(f): pass
1260 class A:
1261 @dec # E: Decorators on top of @property are not supported
1262 @property
1263 def f(self) -> int: pass
1264 @property # OK
1265 @dec
1266 def g(self) -> int: pass
1267 @dec # type: ignore[misc]
1268 @property
1269 def h(self) -> int: pass
1270 @dec # type: ignore[prop-decorator]
1271 @property
1272 def i(self) -> int: pass
1273 [builtins fixtures/property.pyi]
1274 [out]
1275
1276 [case testImportTwoModulesWithSameNameInFunction]
1277 import typing
1278 def f() -> None:
1279 import x
1280 import y as x # E: Name "x" already defined (by an import)
1281 x.y
1282 [file x.py]
1283 y = 1
1284 [file y.py]
1285 [out]
1286
1287 [case testImportTwoModulesWithSameNameInGlobalContext]
1288 import typing
1289 import x
1290 import y as x # E: Name "x" already defined (by an import)
1291 x.y
1292 [file x.py]
1293 y = 1
1294 [file y.py]
1295 [out]
1296
1297 [case testListTypeAliasWithoutImport]
1298 import typing
1299 def f() -> List[int]: pass
1300 [builtins fixtures/list.pyi]
1301 [out]
1302 main:2: error: Name "List" is not defined
1303 main:2: note: Did you forget to import it from "typing"? (Suggestion: "from typing import List")
1304
1305 [case testInvalidWithTarget]
1306 def f(): pass
1307 with f() as 1: pass
1308 [out]
1309 main:2: error: Cannot assign to literal
1310
1311 [case testInvalidTypeAnnotation]
1312 import typing
1313 def f() -> None:
1314 1[2] = 1 # type: int
1315 [out]
1316 main:3: error: Unexpected type declaration
1317
1318 [case testInvalidTypeAnnotation2]
1319 import typing
1320 def f() -> None:
1321 f() = 1 # type: int
1322 [out]
1323 main:3: error: Cannot assign to function call here. Maybe you meant '==' instead of '='?
1324
1325 [case testInvalidReferenceToAttributeOfOuterClass]
1326 class A:
1327 class X: pass
1328 class B:
1329 y = X # E: Name "X" is not defined
1330 [out]
1331
1332 [case testStubPackage]
1333 from m import x
1334 from m import y # E: Module "m" has no attribute "y"
1335 [file m/__init__.pyi]
1336 x = 1
1337 [out]
1338
1339 [case testStubPackageSubModule]
1340 from m import x
1341 from m import y # E: Module "m" has no attribute "y"
1342 from m.m2 import y
1343 from m.m2 import z # E: Module "m.m2" has no attribute "z"
1344 [file m/__init__.pyi]
1345 x = 1
1346 [file m/m2.pyi]
1347 y = 1
1348 [out]
1349
1350 [case testListComprehensionSpecialScoping]
1351 class A:
1352 x = 1
1353 y = 1
1354 z = 1
1355 [x for i in z if y]
1356 [out]
1357 main:5: error: Name "x" is not defined
1358 main:5: error: Name "y" is not defined
1359
1360 [case testTypeRedeclarationNoSpuriousWarnings]
1361 from typing import Tuple
1362 a = 1 # type: int
1363 a = 's' # type: str
1364 a = ('spam', 'spam', 'eggs', 'spam') # type: Tuple[str]
1365 [builtins fixtures/tuple.pyi]
1366
1367 [out]
1368 main:3: error: Name "a" already defined on line 2
1369 main:4: error: Name "a" already defined on line 2
1370
1371 [case testDuplicateDefFromImport]
1372 from m import A
1373 class A: # E: Name "A" already defined (possibly by an import)
1374 pass
1375 [file m.py]
1376 class A:
1377 pass
1378 [out]
1379
1380 [case testDuplicateDefDec]
1381 from typing import Any
1382 def dec(x: Any) -> Any:
1383 return x
1384 @dec
1385 def f() -> None:
1386 pass
1387 @dec # E: Name "f" already defined on line 4
1388 def f() -> None:
1389 pass
1390 [out]
1391
1392 [case testDuplicateDefOverload]
1393 from typing import overload, Any
1394 if 1:
1395 @overload
1396 def f(x: int) -> None:
1397 pass
1398 @overload
1399 def f(x: str) -> None:
1400 pass
1401 def f(x: Any) -> None:
1402 pass
1403 else:
1404 def f(x: str) -> None: # E: Name "f" already defined on line 3
1405 pass
1406 [out]
1407
1408 [case testDuplicateDefNT]
1409 from typing import NamedTuple
1410 N = NamedTuple('N', [('a', int),
1411 ('b', str)])
1412
1413 class N: # E: Name "N" already defined on line 2
1414 pass
1415 [builtins fixtures/tuple.pyi]
1416 [out]
1417
1418 [case testDuplicateDefTypedDict]
1419 from typing import TypedDict
1420 Point = TypedDict('Point', {'x': int, 'y': int})
1421
1422 class Point: # E: Name "Point" already defined on line 2
1423 pass
1424 [builtins fixtures/dict.pyi]
1425 [typing fixtures/typing-typeddict.pyi]
1426
1427 [out]
1428
1429 [case testTypeVarClassDup]
1430 from typing import TypeVar
1431 T = TypeVar('T')
1432 class T: ... # E: Name "T" already defined on line 2
1433
1434 [out]
1435
1436 [case testAliasDup]
1437 from typing import List
1438 A = List[int]
1439 class A: ... # E: Name "A" already defined on line 2
1440
1441 [builtins fixtures/list.pyi]
1442 [out]
1443
1444 [case testNoInvalidTypeInDynamicFunctions]
1445
1446 from typing import Dict, TypeVar
1447 T = TypeVar('T')
1448
1449 def f(): # Note no annotation
1450 x: Dict[str, T] = {}
1451 y: T
1452 z: x
1453 def nested(): pass
1454 t: nested
1455
1456 def g() -> None:
1457 x: Dict[str, T] = {} # E: Type variable "__main__.T" is unbound \
1458 # N: (Hint: Use "Generic[T]" or "Protocol[T]" base class to bind "T" inside a class) \
1459 # N: (Hint: Use "T" in function signature to bind "T" inside a function)
1460 [builtins fixtures/dict.pyi]
1461 [out]
1462
1463 [case testParamSpec]
1464 from typing_extensions import ParamSpec
1465
1466 TParams = ParamSpec('TParams')
1467 TP = ParamSpec('?') # E: String argument 1 "?" to ParamSpec(...) does not match variable name "TP"
1468 TP2: int = ParamSpec('TP2') # E: Cannot declare the type of a TypeVar or similar construct
1469
1470 [out]
1471
1472
1473 [case testBaseClassAnnotatedWithoutArgs]
1474 # https://github.com/python/mypy/issues/11808
1475 from typing_extensions import Annotated
1476 # Next line should not crash:
1477 class A(Annotated): pass # E: Annotated[...] must have exactly one type argument and at least one annotation
1478
1479 [case testInvalidUnpackTypes]
1480 from typing_extensions import Unpack
1481 from typing import Tuple
1482
1483 heterogenous_tuple: Tuple[Unpack[Tuple[int, str]]]
1484 homogeneous_tuple: Tuple[Unpack[Tuple[int, ...]]]
1485 bad: Tuple[Unpack[int]] # E: "int" cannot be unpacked (must be tuple or TypeVarTuple)
1486 [builtins fixtures/tuple.pyi]
1487
1488 [case testTypeVarTupleErrors]
1489 from typing import Generic
1490 from typing_extensions import TypeVarTuple, Unpack
1491
1492 TVariadic = TypeVarTuple('TVariadic')
1493 TVariadic2 = TypeVarTuple('TVariadic2')
1494 TP = TypeVarTuple('?') # E: String argument 1 "?" to TypeVarTuple(...) does not match variable name "TP"
1495 TP2: int = TypeVarTuple('TP2') # E: Cannot declare the type of a TypeVar or similar construct
1496 TP3 = TypeVarTuple() # E: Too few arguments for TypeVarTuple()
1497 TP4 = TypeVarTuple('TP4', 'TP4') # E: Too many positional arguments for "TypeVarTuple"
1498 TP5 = TypeVarTuple(t='TP5') # E: TypeVarTuple() expects a string literal as first argument
1499 TP6 = TypeVarTuple('TP6', bound=int) # E: Unexpected keyword argument "bound" for "TypeVarTuple"
1500
1501 x: TVariadic # E: TypeVarTuple "TVariadic" is unbound
1502 y: Unpack[TVariadic] # E: Unpack is only valid in a variadic position
1503
1504
1505 class Variadic(Generic[Unpack[TVariadic], Unpack[TVariadic2]]): # E: Can only use one type var tuple in a class def
1506 pass
1507
1508 def bad_args(*args: TVariadic): # E: TypeVarTuple "TVariadic" is only valid with an unpack
1509 pass
1510
1511 def bad_kwargs(**kwargs: Unpack[TVariadic]): # E: Unpack item in ** parameter must be a TypedDict
1512 pass
1513
1514 [builtins fixtures/dict.pyi]