Skip to content

Commit 106867e

Browse files
committed
Fix some fine-grained incremental bugs with newly imported files
1 parent 71d85d7 commit 106867e

File tree

2 files changed

+53
-3
lines changed

2 files changed

+53
-3
lines changed

mypy/server/update.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ def update(self, changed_modules: List[Tuple[str, str]]) -> List[str]:
225225
messages, remaining, (next_id, next_path), blocker = result
226226
changed_modules = [(id, path) for id, path in changed_modules
227227
if id != next_id]
228-
changed_modules = dedupe_modules(changed_modules + remaining)
228+
changed_modules = dedupe_modules(remaining + changed_modules)
229229
if blocker:
230230
self.blocking_error = (next_id, next_path)
231231
self.stale = changed_modules
@@ -284,7 +284,7 @@ def update_single(self, module: str, path: str) -> Tuple[List[str],
284284
propagate_changes_using_dependencies(manager, graph, self.deps, triggered,
285285
{module},
286286
self.previous_targets_with_errors,
287-
graph)
287+
self.manager.modules)
288288

289289
# Preserve state needed for the next update.
290290
self.previous_targets_with_errors = manager.errors.targets()
@@ -408,7 +408,10 @@ def update_single_isolated(module: str,
408408
remaining_modules = changed_modules
409409
# The remaining modules haven't been processed yet so drop them.
410410
for id, _ in remaining_modules:
411-
del manager.modules[id]
411+
if id in old_modules:
412+
manager.modules[id] = old_modules[id]
413+
else:
414+
del manager.modules[id]
412415
del graph[id]
413416
if DEBUG:
414417
print('--> %r (newly imported)' % module)

test-data/unit/fine-grained-modules.test

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -746,3 +746,50 @@ x = 1
746746
[delete a/b.py.2]
747747
[out]
748748
==
749+
750+
[case testAddImport]
751+
import what.b
752+
[file aaa/__init__.py]
753+
[file aaa/z.py]
754+
def foo(x: int) -> None:
755+
pass
756+
[file aaa/z.py.2]
757+
import config
758+
def foo() -> None:
759+
pass
760+
[file what/__init__.py]
761+
[file what/b.py]
762+
import config
763+
import aaa.z
764+
def main() -> None:
765+
aaa.z.foo(5)
766+
[file what/b.py.2]
767+
import aaa.z
768+
def main() -> None:
769+
aaa.z.foo()
770+
[file config.py]
771+
[out]
772+
==
773+
774+
[case testAddImport2]
775+
import what.b
776+
[file aaa/__init__.py]
777+
[file aaa/z.py]
778+
def foo(x: int) -> None:
779+
pass
780+
[file aaa/z.py.2]
781+
def foo() -> None:
782+
pass
783+
[file what/__init__.py]
784+
[file what/b.py]
785+
import aaa.z
786+
def main() -> None:
787+
aaa.z.foo(5)
788+
[file what/b.py.2]
789+
import config
790+
import aaa.z
791+
def main() -> None:
792+
aaa.z.foo()
793+
[file config.py]
794+
[out]
795+
==

0 commit comments

Comments
 (0)