@@ -17,7 +17,7 @@ main:3: error: Name 'y' is not defined
17
17
18
18
[case testUndefinedVariableWithinFunctionContext]
19
19
import typing
20
- def f():
20
+ def f() -> None :
21
21
x
22
22
y
23
23
[out]
@@ -39,7 +39,7 @@ import typing
39
39
class A:
40
40
def f(self): pass
41
41
class B:
42
- def g(self):
42
+ def g(self) -> None :
43
43
f # error
44
44
g # error
45
45
[out]
@@ -178,7 +178,7 @@ main:4: error: Name 'x' already defined
178
178
[case testLocalVarRedefinition]
179
179
import typing
180
180
class A: pass
181
- def f():
181
+ def f() -> None :
182
182
x = 0 # type: A
183
183
x = 0 # type: A
184
184
[out]
@@ -523,7 +523,7 @@ main:4: error: Invalid type "__main__.t"
523
523
from typing import TypeVar, Generic
524
524
t = TypeVar('t')
525
525
class c(Generic[t]):
526
- def f(self): x = t
526
+ def f(self) -> None : x = t
527
527
def f(y: t): x = t
528
528
[out]
529
529
main: note: In function "f":
@@ -546,7 +546,7 @@ main:2: error: Name 'B' is not defined
546
546
[case testSuperOutsideClass]
547
547
class A: pass
548
548
super().x
549
- def f(): super().y
549
+ def f() -> None : super().y
550
550
[out]
551
551
main:2: error: "super" used outside class
552
552
main: note: In function "f":
@@ -572,7 +572,7 @@ main:5: error: Name 'f' already defined
572
572
573
573
[case testInvalidGlobalDecl]
574
574
import typing
575
- def f():
575
+ def f() -> None :
576
576
global x
577
577
x = None
578
578
[out]
@@ -582,7 +582,7 @@ main:4: error: Name 'x' is not defined
582
582
[case testInvalidNonlocalDecl]
583
583
import typing
584
584
def f():
585
- def g():
585
+ def g() -> None :
586
586
nonlocal x
587
587
x = None
588
588
[out]
@@ -593,7 +593,7 @@ main:5: error: Name 'x' is not defined
593
593
[case testNonlocalDeclNotMatchingGlobal]
594
594
import typing
595
595
x = None
596
- def f():
596
+ def f() -> None :
597
597
nonlocal x
598
598
x = None
599
599
[out]
@@ -605,7 +605,7 @@ main:5: error: Name 'x' is not defined
605
605
import typing
606
606
def g():
607
607
x = None
608
- def f(x):
608
+ def f(x) -> None :
609
609
nonlocal x
610
610
x = None
611
611
[out]
@@ -623,7 +623,7 @@ import typing
623
623
x = 1
624
624
def f():
625
625
x = 1
626
- def g():
626
+ def g() -> None :
627
627
global x
628
628
nonlocal x
629
629
x = None
@@ -636,7 +636,7 @@ import typing
636
636
x = 1
637
637
def f():
638
638
x = 1
639
- def g():
639
+ def g() -> None :
640
640
nonlocal x
641
641
global x
642
642
x = None
@@ -646,7 +646,7 @@ main:7: error: Name 'x' is nonlocal and global
646
646
647
647
[case testNestedFunctionAndScoping]
648
648
import typing
649
- def f(x):
649
+ def f(x) -> None :
650
650
def g(y):
651
651
z = x
652
652
z
@@ -659,7 +659,7 @@ main:6: error: Name 'y' is not defined
659
659
660
660
[case testMultipleNestedFunctionDef]
661
661
import typing
662
- def f(x):
662
+ def f(x) -> None :
663
663
def g(): pass
664
664
x = 1
665
665
def g(): pass
@@ -669,7 +669,7 @@ main:5: error: Name 'g' already defined
669
669
670
670
[case testRedefinedOverloadedFunction]
671
671
from typing import overload, Any
672
- def f():
672
+ def f() -> None :
673
673
@overload
674
674
def p(o: object) -> None: pass # no error
675
675
@overload
@@ -683,8 +683,8 @@ main:8: error: Name 'p' already defined
683
683
[case testNestedFunctionInMethod]
684
684
import typing
685
685
class A:
686
- def f(self):
687
- def g():
686
+ def f(self) -> None :
687
+ def g() -> None :
688
688
x
689
689
y
690
690
[out]
@@ -861,7 +861,7 @@ main:3: error: 'abstractmethod' used with a non-method
861
861
[case testAbstractNestedFunction]
862
862
import typing
863
863
from abc import abstractmethod
864
- def g():
864
+ def g() -> None :
865
865
@abstractmethod
866
866
def foo(): pass
867
867
[out]
@@ -1133,7 +1133,7 @@ import typing
1133
1133
@staticmethod
1134
1134
def f(): pass
1135
1135
class A:
1136
- def g(self):
1136
+ def g(self) -> None :
1137
1137
@staticmethod
1138
1138
def h(): pass
1139
1139
[builtins fixtures/staticmethod.py]
@@ -1147,7 +1147,7 @@ import typing
1147
1147
@classmethod
1148
1148
def f(): pass
1149
1149
class A:
1150
- def g(self):
1150
+ def g(self) -> None :
1151
1151
@classmethod
1152
1152
def h(): pass
1153
1153
[builtins fixtures/classmethod.py]
0 commit comments