Skip to content
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

Fix fine-grained crash caused by unneeded extra parse_file()s #4980

Merged
merged 1 commit into from
Apr 27, 2018
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
9 changes: 0 additions & 9 deletions mypy/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -1669,10 +1669,6 @@ def is_fresh(self) -> bool:
def is_interface_fresh(self) -> bool:
return self.externally_same

def has_new_submodules(self) -> bool:
"""Return if this module has new submodules after being loaded from a warm cache."""
return self.meta is not None and self.child_modules != set(self.meta.child_modules)

def mark_as_rechecked(self) -> None:
"""Marks this module as having been fully re-analyzed by the type-checker."""
self.manager.rechecked_modules.add(self.id)
Expand Down Expand Up @@ -2405,11 +2401,6 @@ def load_graph(sources: List[BuildSource], manager: BuildManager,
if dep in st.suppressed:
st.suppressed.remove(dep)
st.dependencies.append(dep)
for id, g in graph.items():
if g.has_new_submodules():
g.parse_file()
g.fix_suppressed_dependencies(graph)
g.mark_interface_stale()
return graph


Expand Down
5 changes: 3 additions & 2 deletions mypy/server/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,8 +399,9 @@ def ensure_trees_loaded(manager: BuildManager, graph: Dict[str, State],
"""Ensure that the modules in initial and their deps have loaded trees."""
to_process = find_unloaded_deps(manager, graph, initial)
if to_process:
manager.log_fine_grained("Calling process_fresh_modules on set of size {} ({})".format(
len(to_process), to_process))
if is_verbose(manager):
manager.log_fine_grained("Calling process_fresh_modules on set of size {} ({})".format(
len(to_process), sorted(to_process)))
process_fresh_modules(graph, to_process, manager)


Expand Down
3 changes: 2 additions & 1 deletion test-data/unit/check-incremental.test
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,8 @@ from parent import b

[file parent/b.py.2]

[stale parent, parent.a, parent.b]
[stale parent.a, parent.b]
[rechecked parent, parent.a, parent.b]

[case testIncrementalReferenceExistingFileWithImportFrom]
from parent import a, b
Expand Down
12 changes: 12 additions & 0 deletions test-data/unit/fine-grained-modules.test
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,18 @@ main:1: error: Cannot find module named 'p.q'
main:1: note: (Perhaps setting MYPYPATH or using the "--ignore-missing-imports" flag would help)
==

[case testDeleteSubpackageWithNontrivialParent1]
[file p/__init__.py]
def g() -> None:
pass
[file p/b.py.2]
def foo() -> None: pass
foo()
[delete p/b.py.3]
[out]
==
==

[case testDeleteModuleWithError]
import a
[file a.py]
Expand Down