From 161a2ec6746310b40f3224d5f4b0490fd13919e9 Mon Sep 17 00:00:00 2001 From: Ryan Gonzalez Date: Mon, 27 Mar 2017 12:15:16 -0500 Subject: [PATCH 1/2] Fix #2308: Keep suppressed imports in the suppressed list --- mypy/build.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mypy/build.py b/mypy/build.py index edda95a1c220..42535f007f54 100644 --- a/mypy/build.py +++ b/mypy/build.py @@ -1665,6 +1665,9 @@ def load_graph(sources: List[BuildSource], manager: BuildManager) -> Graph: assert newst.id not in graph, newst.id graph[newst.id] = newst new.append(newst) + elif ignored: + manager.missing_modules.add(dep) + if dep in st.ancestors and dep in graph: graph[dep].child_modules.add(st.id) if dep in graph and dep in st.suppressed: From 002045c239c3f2bd85a5ca7ec45402788f839584 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Tue, 28 Mar 2017 10:00:32 -0700 Subject: [PATCH 2/2] Simplify logic Swap the if/elif branches so each condition gets tested only once. --- mypy/build.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/mypy/build.py b/mypy/build.py index 42535f007f54..51e82e6a8543 100644 --- a/mypy/build.py +++ b/mypy/build.py @@ -1647,7 +1647,9 @@ def load_graph(sources: List[BuildSource], manager: BuildManager) -> Graph: # so we ignore any suppressed module not explicitly re-included # from the command line. ignored = dep in st.suppressed and dep not in entry_points - if dep not in graph and not ignored: + if ignored: + manager.missing_modules.add(dep) + elif dep not in graph: try: if dep in st.ancestors: # TODO: Why not 'if dep not in st.dependencies' ? @@ -1665,9 +1667,6 @@ def load_graph(sources: List[BuildSource], manager: BuildManager) -> Graph: assert newst.id not in graph, newst.id graph[newst.id] = newst new.append(newst) - elif ignored: - manager.missing_modules.add(dep) - if dep in st.ancestors and dep in graph: graph[dep].child_modules.add(st.id) if dep in graph and dep in st.suppressed: