Skip to content

Commit 073ed86

Browse files
author
hauntsaninja
committed
make mypyc issues go away
1 parent b93491a commit 073ed86

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

mypy/semanal.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
from contextlib import contextmanager
5353

5454
from typing import (
55-
List, Dict, Set, Tuple, cast, TypeVar, Union, Optional, Callable, Iterator, Iterable
55+
Any, List, Dict, Set, Tuple, cast, TypeVar, Union, Optional, Callable, Iterator, Iterable
5656
)
5757
from typing_extensions import Final, TypeAlias as _TypeAlias
5858

@@ -4789,6 +4789,10 @@ def add_imported_symbol(self,
47894789
assert not module_hidden or not module_public
47904790

47914791
symbol_node: Optional[SymbolNode] = node.node
4792+
# I promise this type checks; I'm just making mypyc issues go away.
4793+
# mypyc is absolutely convinced that `symbol_node` narrows to a Var in the following,
4794+
# when it can also be a FuncBase.
4795+
symbol_node_any: Any = cast(Any, symbol_node)
47924796
if self.is_class_scope() and isinstance(symbol_node, (FuncBase, Var)):
47934797
# We construct a new node to represent this symbol and set its `info` attribute
47944798
# to `self.type`. Note that imports inside class scope do not produce methods, so
@@ -4799,14 +4803,14 @@ def add_imported_symbol(self,
47994803
# constructed Var, so check for possible redefinitions here.
48004804
existing is not None
48014805
and isinstance(existing.node, (FuncBase, Var))
4802-
and existing.type == symbol_node.type
4806+
and existing.type == symbol_node_any.type
48034807
):
48044808
symbol_node = existing.node
48054809
else:
48064810
if isinstance(symbol_node, Var):
4807-
symbol_node = Var(symbol_node.name, symbol_node.type)
4811+
symbol_node = Var(symbol_node_any.name, symbol_node_any.type)
48084812
elif isinstance(symbol_node, FuncBase):
4809-
symbol_node = copy.copy(symbol_node)
4813+
symbol_node = copy.copy(symbol_node_any)
48104814
else:
48114815
assert False
48124816
assert self.type is not None

0 commit comments

Comments
 (0)