Skip to content

Commit 7f4dc0d

Browse files
author
Guido van Rossum
committed
Rough and tumble fix to make tests pass. Not sure all these are right. Please review.
1 parent 4e08246 commit 7f4dc0d

File tree

3 files changed

+20
-28
lines changed

3 files changed

+20
-28
lines changed

mypy/test/data/check-weak-typing.test

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,6 @@ def f():
123123
1 + 'a' # E: Unsupported left operand type for + ("int")
124124
[out]
125125
main: note: In function "f":
126-
[case testNonWeakFunction]
127-
def f():
128-
if y: # E: Name 'y' is not defined
129-
x = 1
130-
else:
131-
x = 'a'
132-
[out]
133-
main: note: In function "f":
134126
[case testWeakFunctionCall]
135127
# mypy: weak=global
136128
def f(a: str) -> None: pass

mypy/test/data/semanal-errors.test

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ main:3: error: Name 'y' is not defined
1717

1818
[case testUndefinedVariableWithinFunctionContext]
1919
import typing
20-
def f():
20+
def f() -> None:
2121
x
2222
y
2323
[out]
@@ -39,7 +39,7 @@ import typing
3939
class A:
4040
def f(self): pass
4141
class B:
42-
def g(self):
42+
def g(self) -> None:
4343
f # error
4444
g # error
4545
[out]
@@ -178,7 +178,7 @@ main:4: error: Name 'x' already defined
178178
[case testLocalVarRedefinition]
179179
import typing
180180
class A: pass
181-
def f():
181+
def f() -> None:
182182
x = 0 # type: A
183183
x = 0 # type: A
184184
[out]
@@ -523,7 +523,7 @@ main:4: error: Invalid type "__main__.t"
523523
from typing import TypeVar, Generic
524524
t = TypeVar('t')
525525
class c(Generic[t]):
526-
def f(self): x = t
526+
def f(self) -> None: x = t
527527
def f(y: t): x = t
528528
[out]
529529
main: note: In function "f":
@@ -546,7 +546,7 @@ main:2: error: Name 'B' is not defined
546546
[case testSuperOutsideClass]
547547
class A: pass
548548
super().x
549-
def f(): super().y
549+
def f() -> None: super().y
550550
[out]
551551
main:2: error: "super" used outside class
552552
main: note: In function "f":
@@ -572,7 +572,7 @@ main:5: error: Name 'f' already defined
572572

573573
[case testInvalidGlobalDecl]
574574
import typing
575-
def f():
575+
def f() -> None:
576576
global x
577577
x = None
578578
[out]
@@ -582,7 +582,7 @@ main:4: error: Name 'x' is not defined
582582
[case testInvalidNonlocalDecl]
583583
import typing
584584
def f():
585-
def g():
585+
def g() -> None:
586586
nonlocal x
587587
x = None
588588
[out]
@@ -593,7 +593,7 @@ main:5: error: Name 'x' is not defined
593593
[case testNonlocalDeclNotMatchingGlobal]
594594
import typing
595595
x = None
596-
def f():
596+
def f() -> None:
597597
nonlocal x
598598
x = None
599599
[out]
@@ -605,7 +605,7 @@ main:5: error: Name 'x' is not defined
605605
import typing
606606
def g():
607607
x = None
608-
def f(x):
608+
def f(x) -> None:
609609
nonlocal x
610610
x = None
611611
[out]
@@ -623,7 +623,7 @@ import typing
623623
x = 1
624624
def f():
625625
x = 1
626-
def g():
626+
def g() -> None:
627627
global x
628628
nonlocal x
629629
x = None
@@ -636,7 +636,7 @@ import typing
636636
x = 1
637637
def f():
638638
x = 1
639-
def g():
639+
def g() -> None:
640640
nonlocal x
641641
global x
642642
x = None
@@ -646,7 +646,7 @@ main:7: error: Name 'x' is nonlocal and global
646646

647647
[case testNestedFunctionAndScoping]
648648
import typing
649-
def f(x):
649+
def f(x) -> None:
650650
def g(y):
651651
z = x
652652
z
@@ -659,7 +659,7 @@ main:6: error: Name 'y' is not defined
659659

660660
[case testMultipleNestedFunctionDef]
661661
import typing
662-
def f(x):
662+
def f(x) -> None:
663663
def g(): pass
664664
x = 1
665665
def g(): pass
@@ -669,7 +669,7 @@ main:5: error: Name 'g' already defined
669669

670670
[case testRedefinedOverloadedFunction]
671671
from typing import overload, Any
672-
def f():
672+
def f() -> None:
673673
@overload
674674
def p(o: object) -> None: pass # no error
675675
@overload
@@ -683,8 +683,8 @@ main:8: error: Name 'p' already defined
683683
[case testNestedFunctionInMethod]
684684
import typing
685685
class A:
686-
def f(self):
687-
def g():
686+
def f(self) -> None:
687+
def g() -> None:
688688
x
689689
y
690690
[out]
@@ -861,7 +861,7 @@ main:3: error: 'abstractmethod' used with a non-method
861861
[case testAbstractNestedFunction]
862862
import typing
863863
from abc import abstractmethod
864-
def g():
864+
def g() -> None:
865865
@abstractmethod
866866
def foo(): pass
867867
[out]
@@ -1133,7 +1133,7 @@ import typing
11331133
@staticmethod
11341134
def f(): pass
11351135
class A:
1136-
def g(self):
1136+
def g(self) -> None:
11371137
@staticmethod
11381138
def h(): pass
11391139
[builtins fixtures/staticmethod.py]
@@ -1147,7 +1147,7 @@ import typing
11471147
@classmethod
11481148
def f(): pass
11491149
class A:
1150-
def g(self):
1150+
def g(self) -> None:
11511151
@classmethod
11521152
def h(): pass
11531153
[builtins fixtures/classmethod.py]

mypy/test/data/semanal-statements.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ MypyFile:1(
534534
IntExpr(0)))))))
535535

536536
[case testDelMultipleThingsInvalid]
537-
def f(x, y):
537+
def f(x, y) -> None:
538538
del x, y + 1
539539
[out]
540540
main: note: In function "f":

0 commit comments

Comments
 (0)