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

Function replace_modules_with_new_variants

mypy/server/update.py:811–832  ·  view source on GitHub ↗

Replace modules with newly builds versions. Retain the identities of externally visible AST nodes in the old ASTs so that references to the affected modules from other modules will still be valid (unless something was deleted or replaced with an incompatible definition, in which cas

(
    manager: BuildManager,
    graph: dict[str, State],
    old_modules: dict[str, MypyFile | None],
    new_modules: dict[str, MypyFile | None],
)

Source from the content-addressed store, hash-verified

809
810
811def replace_modules_with_new_variants(
812 manager: BuildManager,
813 graph: dict[str, State],
814 old_modules: dict[str, MypyFile | None],
815 new_modules: dict[str, MypyFile | None],
816) -> None:
817 """Replace modules with newly builds versions.
818
819 Retain the identities of externally visible AST nodes in the
820 old ASTs so that references to the affected modules from other
821 modules will still be valid (unless something was deleted or
822 replaced with an incompatible definition, in which case there
823 will be dangling references that will be handled by
824 propagate_changes_using_dependencies).
825 """
826 for id in new_modules:
827 preserved_module = old_modules.get(id)
828 new_module = new_modules[id]
829 if preserved_module and new_module is not None:
830 merge_asts(preserved_module, preserved_module.names, new_module, new_module.names)
831 manager.modules[id] = preserved_module
832 graph[id].tree = preserved_module
833
834
835def propagate_changes_using_dependencies(

Callers 1

update_module_isolatedFunction · 0.85

Calls 2

merge_astsFunction · 0.90
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…