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 some fine-grained incremental bugs with newly imported files #4502

Merged
merged 2 commits into from
Jan 26, 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
15 changes: 8 additions & 7 deletions mypy/server/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def update(self, changed_modules: List[Tuple[str, str]]) -> List[str]:
messages, remaining, (next_id, next_path), blocker = result
changed_modules = [(id, path) for id, path in changed_modules
if id != next_id]
changed_modules = dedupe_modules(changed_modules + remaining)
changed_modules = dedupe_modules(remaining + changed_modules)
if blocker:
self.blocking_error = (next_id, next_path)
self.stale = changed_modules
Expand Down Expand Up @@ -283,8 +283,7 @@ def update_single(self, module: str, path: str) -> Tuple[List[str],
update_dependencies({module: tree}, self.deps, graph, self.options)
propagate_changes_using_dependencies(manager, graph, self.deps, triggered,
{module},
self.previous_targets_with_errors,
graph)
self.previous_targets_with_errors)

# Preserve state needed for the next update.
self.previous_targets_with_errors = manager.errors.targets()
Expand Down Expand Up @@ -408,7 +407,10 @@ def update_single_isolated(module: str,
remaining_modules = changed_modules
# The remaining modules haven't been processed yet so drop them.
for id, _ in remaining_modules:
del manager.modules[id]
if id in old_modules:
manager.modules[id] = old_modules[id]
else:
del manager.modules[id]
del graph[id]
if DEBUG:
print('--> %r (newly imported)' % module)
Expand Down Expand Up @@ -715,8 +717,7 @@ def propagate_changes_using_dependencies(
deps: Dict[str, Set[str]],
triggered: Set[str],
up_to_date_modules: Set[str],
targets_with_errors: Set[str],
modules: Iterable[str]) -> None:
targets_with_errors: Set[str]) -> None:
# TODO: Multiple type checking passes
num_iter = 0

Expand All @@ -731,7 +732,7 @@ def propagate_changes_using_dependencies(
# Also process targets that used to have errors, as otherwise some
# errors might be lost.
for target in targets_with_errors:
id = module_prefix(modules, target)
id = module_prefix(manager.modules, target)
if id is not None and id not in up_to_date_modules:
if id not in todo:
todo[id] = set()
Expand Down
47 changes: 47 additions & 0 deletions test-data/unit/fine-grained-modules.test
Original file line number Diff line number Diff line change
Expand Up @@ -746,3 +746,50 @@ x = 1
[delete a/b.py.2]
[out]
==

[case testAddImport]
import what.b
[file aaa/__init__.py]
[file aaa/z.py]
def foo(x: int) -> None:
pass
[file aaa/z.py.2]
import config
def foo() -> None:
pass
[file what/__init__.py]
[file what/b.py]
import config
import aaa.z
def main() -> None:
aaa.z.foo(5)
[file what/b.py.2]
import aaa.z
def main() -> None:
aaa.z.foo()
[file config.py]
[out]
==

[case testAddImport2]
import what.b
[file aaa/__init__.py]
[file aaa/z.py]
def foo(x: int) -> None:
pass
[file aaa/z.py.2]
def foo() -> None:
pass
[file what/__init__.py]
[file what/b.py]
import aaa.z
def main() -> None:
aaa.z.foo(5)
[file what/b.py.2]
import config
import aaa.z
def main() -> None:
aaa.z.foo()
[file config.py]
[out]
==