MCPcopy Index your code
hub / github.com/python/mypy / update_module_isolated

Function update_module_isolated

mypy/server/update.py:562–683  ·  view source on GitHub ↗

Build a new version of one changed module only. Don't propagate changes to elsewhere in the program. Raise CompileError on encountering a blocking error. Args: module: Changed module (modified, created or deleted) path: Path of the changed module manager: Build

(
    module: str,
    path: str,
    manager: BuildManager,
    previous_modules: dict[str, str],
    graph: Graph,
    force_removed: bool,
    followed: bool,
)

Source from the content-addressed store, hash-verified

560
561
562def update_module_isolated(
563 module: str,
564 path: str,
565 manager: BuildManager,
566 previous_modules: dict[str, str],
567 graph: Graph,
568 force_removed: bool,
569 followed: bool,
570) -> UpdateResult:
571 """Build a new version of one changed module only.
572
573 Don't propagate changes to elsewhere in the program. Raise CompileError on
574 encountering a blocking error.
575
576 Args:
577 module: Changed module (modified, created or deleted)
578 path: Path of the changed module
579 manager: Build manager
580 graph: Build graph
581 force_removed: If True, consider the module removed from the build even it the
582 file exists
583
584 Returns a named tuple describing the result (see above for details).
585 """
586 if module not in graph:
587 manager.log_fine_grained(f"new module {module!r}")
588
589 if not manager.fscache.isfile(path) or force_removed:
590 delete_module(module, path, graph, manager)
591 return NormalUpdate(module, path, [], None)
592
593 sources = get_sources(manager.fscache, previous_modules, [(module, path)], followed)
594
595 if module in manager.missing_modules:
596 del manager.missing_modules[module]
597
598 orig_module = module
599 orig_state = graph.get(module)
600 orig_tree = manager.modules.get(module)
601
602 def restore(ids: list[str]) -> None:
603 # For each of the modules in ids, restore that id's old
604 # manager.modules and graphs entries. (Except for the original
605 # module, this means deleting them.)
606 for id in ids:
607 if id == orig_module and orig_tree:
608 manager.modules[id] = orig_tree
609 elif id in manager.modules:
610 del manager.modules[id]
611 if id == orig_module and orig_state:
612 graph[id] = orig_state
613 elif id in graph:
614 del graph[id]
615
616 new_modules: list[State] = []
617 try:
618 if module in graph:
619 del graph[module]

Callers 1

update_moduleMethod · 0.85

Calls 15

load_graphFunction · 0.90
delete_moduleFunction · 0.85
NormalUpdateClass · 0.85
get_sourcesFunction · 0.85
restoreFunction · 0.85
BlockedUpdateClass · 0.85
ensure_trees_loadedFunction · 0.85
setClass · 0.85
lenFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…