Skip to content

Fix incremental mode when non-compiled classes are imported #8498

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions mypyc/irbuild/prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from mypy.nodes import (
MypyFile, TypeInfo, FuncDef, ClassDef, Decorator, OverloadedFuncDef, MemberExpr, Var,
Expression, ARG_STAR, ARG_STAR2
Expression, SymbolNode, ARG_STAR, ARG_STAR2
)
from mypy.types import Type
from mypy.build import Graph
Expand Down Expand Up @@ -63,13 +63,17 @@ def build_type_map(mapper: Mapper,
# TODO: what else?


def is_from_module(node: SymbolNode, module: MypyFile) -> bool:
return node.fullname == module.fullname + '.' + node.name


def load_type_map(mapper: 'Mapper',
modules: List[MypyFile],
deser_ctx: DeserMaps) -> None:
"""Populate a Mapper with deserialized IR from a list of modules."""
for module in modules:
for name, node in module.names.items():
if isinstance(node.node, TypeInfo):
if isinstance(node.node, TypeInfo) and is_from_module(node.node, module):
ir = deser_ctx.classes[node.node.fullname]
mapper.type_to_ir[node.node] = ir
mapper.func_to_decl[node.node] = ir.ctor
Expand All @@ -86,7 +90,7 @@ def get_module_func_defs(module: MypyFile) -> Iterable[FuncDef]:
# aliases. The best way to do this seems to be by
# checking that the fullname matches.
if (isinstance(node.node, (FuncDef, Decorator, OverloadedFuncDef))
and node.fullname == module.fullname + '.' + name):
and is_from_module(node.node, module)):
yield get_func_def(node.node)


Expand Down
2 changes: 2 additions & 0 deletions mypyc/test-data/run-multimodule.test
Original file line number Diff line number Diff line change
Expand Up @@ -604,12 +604,14 @@ assert non_native.foo() == 0

[file other_a.py]
from other_b import z
from typing import Iterable

class A:
def __init__(self) -> None:
self.y = z
[file other_a.py.2]
from other_b import z
from typing import Iterable

class A:
def __init__(self) -> None:
Expand Down