Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ad400e3

Browse files
committed
Merge branch 'ecprice-breaking_out'
2 parents 77206d5 + 085bf6d commit ad400e3

3 files changed

Lines changed: 14 additions & 7 deletions

File tree

mypy/checker.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1737,9 +1737,7 @@ def visit_name_expr(self, e: NameExpr) -> Type:
17371737
return self.expr_checker.visit_name_expr(e)
17381738

17391739
def visit_call_expr(self, e: CallExpr) -> Type:
1740-
result = self.expr_checker.visit_call_expr(e)
1741-
self.breaking_out = False
1742-
return result
1740+
return self.expr_checker.visit_call_expr(e)
17431741

17441742
def visit_yield_from_expr(self, e: YieldFromExpr) -> Type:
17451743
# result = self.expr_checker.visit_yield_from_expr(e)

mypy/test/data/check-isinstance.test

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,3 +761,15 @@ y = C() # type: A
761761
if isinstance(x, B) and isinstance(y, int):
762762
1() # type checking skipped
763763
[builtins fixtures/isinstancelist.py]
764+
765+
[case testReturnWithCallExprAndIsinstance]
766+
767+
from typing import Union
768+
def f(x: Union[int, str]) -> None:
769+
if not isinstance(x, int):
770+
return foo()
771+
x() # E: "int" not callable
772+
def foo(): pass
773+
[builtins fixtures/isinstancelist.py]
774+
[out]
775+
main: note: In function "f":

mypy/test/data/check-statements.test

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,15 @@
66
import typing
77
def f() -> 'A':
88
return A()
9-
return B()
109
def g() -> 'B':
1110
return A()
1211
class A:
1312
pass
1413
class B:
1514
pass
1615
[out]
17-
main: note: In function "f":
18-
main:4: error: Incompatible return value type: expected __main__.A, got __main__.B
1916
main: note: In function "g":
20-
main:6: error: Incompatible return value type: expected __main__.B, got __main__.A
17+
main:5: error: Incompatible return value type: expected __main__.B, got __main__.A
2118

2219
[case testReturnSubtype]
2320
import typing

0 commit comments

Comments
 (0)