MCPcopy Create free account
hub / github.com/python/mypy / lookup_target

Function lookup_target

mypy/server/update.py:1099–1122  ·  view source on GitHub ↗

Look up a target by fully-qualified name. The first item in the return tuple is a list of deferred nodes that needs to be reprocessed. If the target represents a TypeInfo corresponding to a protocol, return it as a second item in the return tuple, otherwise None.

(
    manager: BuildManager, target: str, module_id: str
)

Source from the content-addressed store, hash-verified

1097
1098
1099def lookup_target(
1100 manager: BuildManager, target: str, module_id: str
1101) -> tuple[list[FineGrainedDeferredNode], TypeInfo | None]:
1102 """Look up a target by fully-qualified name.
1103
1104 The first item in the return tuple is a list of deferred nodes that
1105 needs to be reprocessed. If the target represents a TypeInfo corresponding
1106 to a protocol, return it as a second item in the return tuple, otherwise None.
1107 """
1108 deferred, stale_proto = _lookup_target_impl(manager, target)
1109
1110 # If there are function targets that can infer outer variables, they should
1111 # be re-processed as part of the module top-level instead (for consistency).
1112 regular = []
1113 shared = []
1114 for d in deferred:
1115 if isinstance(d.node, FuncBase) and d.node.def_or_infer_vars:
1116 shared.append(d)
1117 else:
1118 regular.append(d)
1119 deferred = regular
1120 if shared:
1121 deferred.append(FineGrainedDeferredNode(manager.modules[module_id], None))
1122 return deferred, stale_proto
1123
1124
1125def _lookup_target_impl(

Callers 2

find_targets_recursiveFunction · 0.85

Calls 4

_lookup_target_implFunction · 0.85
isinstanceFunction · 0.85
appendMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…