Skip to content

Commit 6ea4f4d

Browse files
committed
Apply CR comments
1 parent 7f080a0 commit 6ea4f4d

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

mypy/semanal.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2640,7 +2640,7 @@ def visit_member_expr(self, expr: MemberExpr) -> None:
26402640
# This branch handles the case foo.bar where foo is a module.
26412641
# In this case base.node is the module's MypyFile and we look up
26422642
# bar in its namespace. This must be done for all types of bar.
2643-
file = cast(Optional[MypyFile], base.node)
2643+
file = cast(Optional[MypyFile], base.node) # can't use isinstance due to issue #2999
26442644
n = file.names.get(expr.name, None) if file is not None else None
26452645
if n:
26462646
n = self.normalize_type_alias(n, expr)
@@ -2657,8 +2657,7 @@ def visit_member_expr(self, expr: MemberExpr) -> None:
26572657
# one type checker run. If we reported errors here,
26582658
# the build would terminate after semantic analysis
26592659
# and we wouldn't be able to report any type errors.
2660-
full_name = '%s.%s' % (file.fullname() if file is not None
2661-
else None, expr.name)
2660+
full_name = '%s.%s' % (file.fullname() if file is not None else None, expr.name)
26622661
mod_name = " '%s'" % file.fullname() if file is not None else ''
26632662
if full_name in obsolete_name_mapping:
26642663
self.fail("Module%s has no attribute %r (it's now called %r)" % (

test-data/unit/check-isinstance.test

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,9 +1346,11 @@ def f(x: object) -> None:
13461346
[out]
13471347

13481348
[case testIsInstanceWithUnknownType]
1349-
from typing import *
1349+
from typing import Union
13501350
def f(x: Union[int, str], typ: type) -> None:
13511351
if isinstance(x, (typ, int)):
13521352
x + 1 # E: Unsupported operand types for + (likely involving Union)
1353+
reveal_type(x) # E: Revealed type is 'Union[builtins.int, builtins.str]'
1354+
else:
1355+
reveal_type(x) # E: Revealed type is 'Union[builtins.int, builtins.str]'
13531356
[builtins fixtures/isinstancelist.pyi]
1354-

0 commit comments

Comments
 (0)