Skip to content

Commit 0bf7d6a

Browse files
committed
Fix some fine-grained incremental bugs with newly imported files
1 parent bc686f5 commit 0bf7d6a

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
@@ -223,7 +223,7 @@ def update(self, changed_modules: List[Tuple[str, str]]) -> List[str]:
223223
messages, remaining, (next_id, next_path), blocker = result
224224
changed_modules = [(id, path) for id, path in changed_modules
225225
if id != next_id]
226-
changed_modules = dedupe_modules(changed_modules + remaining)
226+
changed_modules = dedupe_modules(remaining + changed_modules)
227227
if blocker:
228228
self.blocking_error = (next_id, next_path)
229229
self.stale = changed_modules
@@ -282,7 +282,7 @@ def update_single(self, module: str, path: str) -> Tuple[List[str],
282282
propagate_changes_using_dependencies(manager, graph, self.deps, triggered,
283283
{module},
284284
self.previous_targets_with_errors,
285-
graph)
285+
self.manager.modules)
286286

287287
# Preserve state needed for the next update.
288288
self.previous_targets_with_errors = manager.errors.targets()
@@ -406,7 +406,10 @@ def update_single_isolated(module: str,
406406
remaining_modules = changed_modules
407407
# The remaining modules haven't been processed yet so drop them.
408408
for id, _ in remaining_modules:
409-
del manager.modules[id]
409+
if id in old_modules:
410+
manager.modules[id] = old_modules[id]
411+
else:
412+
del manager.modules[id]
410413
del graph[id]
411414
if DEBUG:
412415
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
@@ -631,3 +631,50 @@ x = 1
631631
[delete a/b.py.2]
632632
[out]
633633
==
634+
635+
[case testAddImport]
636+
import what.b
637+
[file aaa/__init__.py]
638+
[file aaa/z.py]
639+
def foo(x: int) -> None:
640+
pass
641+
[file aaa/z.py.2]
642+
import config
643+
def foo() -> None:
644+
pass
645+
[file what/__init__.py]
646+
[file what/b.py]
647+
import config
648+
import aaa.z
649+
def main() -> None:
650+
aaa.z.foo(5)
651+
[file what/b.py.2]
652+
import aaa.z
653+
def main() -> None:
654+
aaa.z.foo()
655+
[file config.py]
656+
[out]
657+
==
658+
659+
[case testAddImport2]
660+
import what.b
661+
[file aaa/__init__.py]
662+
[file aaa/z.py]
663+
def foo(x: int) -> None:
664+
pass
665+
[file aaa/z.py.2]
666+
def foo() -> None:
667+
pass
668+
[file what/__init__.py]
669+
[file what/b.py]
670+
import aaa.z
671+
def main() -> None:
672+
aaa.z.foo(5)
673+
[file what/b.py.2]
674+
import config
675+
import aaa.z
676+
def main() -> None:
677+
aaa.z.foo()
678+
[file config.py]
679+
[out]
680+
==

0 commit comments

Comments
 (0)