52
52
from contextlib import contextmanager
53
53
54
54
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
56
56
)
57
57
from typing_extensions import Final , TypeAlias as _TypeAlias
58
58
@@ -4789,6 +4789,10 @@ def add_imported_symbol(self,
4789
4789
assert not module_hidden or not module_public
4790
4790
4791
4791
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 )
4792
4796
if self .is_class_scope () and isinstance (symbol_node , (FuncBase , Var )):
4793
4797
# We construct a new node to represent this symbol and set its `info` attribute
4794
4798
# to `self.type`. Note that imports inside class scope do not produce methods, so
@@ -4799,14 +4803,14 @@ def add_imported_symbol(self,
4799
4803
# constructed Var, so check for possible redefinitions here.
4800
4804
existing is not None
4801
4805
and isinstance (existing .node , (FuncBase , Var ))
4802
- and existing .type == symbol_node .type
4806
+ and existing .type == symbol_node_any .type
4803
4807
):
4804
4808
symbol_node = existing .node
4805
4809
else :
4806
4810
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 )
4808
4812
elif isinstance (symbol_node , FuncBase ):
4809
- symbol_node = copy .copy (symbol_node )
4813
+ symbol_node = copy .copy (symbol_node_any )
4810
4814
else :
4811
4815
assert False
4812
4816
assert self .type is not None
0 commit comments