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

Method update_module

mypy/server/update.py:380–470  ·  view source on GitHub ↗

Update a single modified module. If the module contains imports of previously unseen modules, only process one of the new modules and return the remaining work to be done. Args: module: Id of the module path: File system path of the module

(
        self, module: str, path: str, force_removed: bool, followed: bool
    )

Source from the content-addressed store, hash-verified

378 return changed_modules, (next_id, next_path), blocker_messages
379
380 def update_module(
381 self, module: str, path: str, force_removed: bool, followed: bool
382 ) -> tuple[list[tuple[str, str]], tuple[str, str], list[str] | None]:
383 """Update a single modified module.
384
385 If the module contains imports of previously unseen modules, only process one of
386 the new modules and return the remaining work to be done.
387
388 Args:
389 module: Id of the module
390 path: File system path of the module
391 force_removed: If True, consider module removed from the build even if path
392 exists (used for removing an existing file from the build)
393 followed: Was this found via import following?
394
395 Returns:
396 Tuple with these items:
397
398 - Remaining modules to process as (module id, path) tuples
399 - Module which was actually processed as (id, path) tuple
400 - If there was a blocking error, the error messages from it
401 """
402 self.manager.log_fine_grained(f"--- update single {module!r} ---")
403 self.updated_modules.append(module)
404
405 # builtins and friends could potentially get triggered because
406 # of protocol stuff, but nothing good could possibly come from
407 # actually updating them.
408 if (
409 is_stdlib_file(self.manager.options.abs_custom_typeshed_dir, path)
410 or module in SENSITIVE_INTERNAL_MODULES
411 ):
412 return [], (module, path), None
413
414 manager = self.manager
415 previous_modules = self.previous_modules
416 graph = self.graph
417
418 ensure_deps_loaded(module, self.deps, graph)
419
420 # If this is an already existing module, make sure that we have
421 # its tree loaded so that we can snapshot it for comparison.
422 ensure_trees_loaded(manager, graph, [module])
423
424 t0 = time.time()
425 # Record symbol table snapshot of old version the changed module.
426 old_snapshots: dict[str, dict[str, SymbolSnapshot]] = {}
427 if module in manager.modules:
428 snapshot = snapshot_symbol_table(module, manager.modules[module].names)
429 old_snapshots[module] = snapshot
430
431 manager.errors.reset()
432 self.processed_targets.append(module)
433 result = update_module_isolated(
434 module, path, manager, previous_modules, graph, force_removed, followed
435 )
436 if isinstance(result, BlockedUpdate):
437 # Blocking error -- just give up

Callers 1

update_oneMethod · 0.95

Calls 15

is_stdlib_fileFunction · 0.90
snapshot_symbol_tableFunction · 0.90
ensure_deps_loadedFunction · 0.85
ensure_trees_loadedFunction · 0.85
update_module_isolatedFunction · 0.85
isinstanceFunction · 0.85
get_module_to_path_mapFunction · 0.85
is_verboseFunction · 0.85
sortedFunction · 0.85
setClass · 0.85

Tested by

no test coverage detected