From 0782c3d9db7f3778a629fdec4c41a15faa1e214f Mon Sep 17 00:00:00 2001 From: Jukka Lehtosalo Date: Tue, 5 Mar 2019 13:35:12 +0000 Subject: [PATCH 1/2] New semantic analyzer: store import deps generated during analysis Previously some module dependencies genererated from `from m import *` went missing, and this could result in crashes when deserialization, since the target module wasn't serialized yet. This fixes one incremental mode test case. --- mypy/newsemanal/semanal_main.py | 4 ++++ test-data/unit/check-newsemanal.test | 15 +++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/mypy/newsemanal/semanal_main.py b/mypy/newsemanal/semanal_main.py index 48fb7ea36c9d..a50b45280865 100644 --- a/mypy/newsemanal/semanal_main.py +++ b/mypy/newsemanal/semanal_main.py @@ -41,6 +41,7 @@ from mypy.errors import Errors from mypy.newsemanal.semanal_infer import infer_decorator_signature_if_simple from mypy.checker import FineGrainedDeferredNode +import mypy.build MYPY = False if MYPY: @@ -278,6 +279,9 @@ def semantic_analyze_target(target: str, analyzer.refresh_partial(refresh_node, patches, final_iteration) if isinstance(node, Decorator): infer_decorator_signature_if_simple(node, analyzer) + for dep in analyzer.imports: + state.dependencies.append(dep) + state.priorities[dep] = mypy.build.PRI_LOW if analyzer.deferred: return [target], analyzer.incomplete, analyzer.progress else: diff --git a/test-data/unit/check-newsemanal.test b/test-data/unit/check-newsemanal.test index 8dd3064bdb7b..f9bea2d6fd97 100644 --- a/test-data/unit/check-newsemanal.test +++ b/test-data/unit/check-newsemanal.test @@ -2020,3 +2020,18 @@ class C(Generic[T]): ... class A: ... class D: ... + +[case testNewAnalyzerAddedSubStarImport_incremental] +# TODO: This can be removed once testAddedSubStarImport is enabled in check-incremental.test. +# cmd: mypy -m a pack pack.mod b +# cmd2: mypy -m other +[file a.py] +from pack import * +[file pack/__init__.py] +[file pack/mod.py] +[file b.py] +import pack.mod +[file other.py] +import a +[out] +[out2] From f12b038df570caaf39c4e8418817fb555aa112cc Mon Sep 17 00:00:00 2001 From: Jukka Lehtosalo Date: Mon, 1 Apr 2019 12:28:58 +0100 Subject: [PATCH 2/2] Don't lower priority --- mypy/newsemanal/semanal_main.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mypy/newsemanal/semanal_main.py b/mypy/newsemanal/semanal_main.py index a50b45280865..3a60df68f85a 100644 --- a/mypy/newsemanal/semanal_main.py +++ b/mypy/newsemanal/semanal_main.py @@ -281,7 +281,9 @@ def semantic_analyze_target(target: str, infer_decorator_signature_if_simple(node, analyzer) for dep in analyzer.imports: state.dependencies.append(dep) - state.priorities[dep] = mypy.build.PRI_LOW + priority = mypy.build.PRI_LOW + if priority <= state.priorities.get(dep, priority): + state.priorities[dep] = priority if analyzer.deferred: return [target], analyzer.incomplete, analyzer.progress else: