Skip to content

Commit 302091e

Browse files
committed
bugfix for join_simple
1 parent 822c094 commit 302091e

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

mypy/join.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ def join_simple(declaration: Type, s: Type, t: Type, basic: BasicTypes) -> Type:
4040
# is a good idea.
4141
return declaration
4242

43-
if is_subtype(value, declaration):
44-
return declaration
43+
if declaration is None or is_subtype(value, declaration):
44+
return value
4545

46-
return value
46+
return declaration
4747

4848

4949

mypy/test/data/check-isinstance.test

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
[case testJoinAny]
2+
from typing import List, Any
3+
4+
x = None # type: List[Any]
5+
6+
def foo() -> List[int]: pass
7+
def bar() -> List[str]: pass
8+
9+
if 1:
10+
x = foo()
11+
else:
12+
x = bar()
13+
14+
x * 2
15+
[builtins fixtures/list.py]
16+
117
[case testGeneratorExpressionTypes]
218

319
class A: y = 1

0 commit comments

Comments
 (0)