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

Method modules_for_nodes

mypy/inspections.py:406–427  ·  view source on GitHub ↗

Gather modules where given nodes where defined. Also check if they need to be refreshed (cached nodes may have lines/columns missing).

(
        self, nodes: list[FuncBase | SymbolNode], expression: RefExpr
    )

Source from the content-addressed store, hash-verified

404 return nodes
405
406 def modules_for_nodes(
407 self, nodes: list[FuncBase | SymbolNode], expression: RefExpr
408 ) -> tuple[dict[FuncBase | SymbolNode, State], bool]:
409 """Gather modules where given nodes where defined.
410
411 Also check if they need to be refreshed (cached nodes may have
412 lines/columns missing).
413 """
414 modules = {}
415 reload_needed = False
416 for node in nodes:
417 module = find_module_by_fullname(node.fullname, self.fg_manager.graph)
418 if not module:
419 if expression.kind == LDEF and self.module:
420 module = self.module
421 else:
422 continue
423 modules[node] = module
424 if not module.tree or module.tree.is_cache_skeleton or self.force_reload:
425 reload_needed |= not module.tree or module.tree.is_cache_skeleton
426 self.reload_module(module)
427 return modules, reload_needed
428
429 def expression_def(self, expression: Expression) -> tuple[str, bool]:
430 """Find and format definition location for an expression.

Callers 1

expression_defMethod · 0.95

Calls 2

reload_moduleMethod · 0.95
find_module_by_fullnameFunction · 0.85

Tested by

no test coverage detected