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

Function target_from_node

mypy/server/update.py:1200–1218  ·  view source on GitHub ↗

Return the target name corresponding to a deferred node. Args: module: Must be module id of the module that defines 'node' Returns the target name, or None if the node is not a valid target in the given module (for example, if it's actually defined in another module).

(module: str, node: FuncDef | MypyFile | OverloadedFuncDef)

Source from the content-addressed store, hash-verified

1198
1199
1200def target_from_node(module: str, node: FuncDef | MypyFile | OverloadedFuncDef) -> str | None:
1201 """Return the target name corresponding to a deferred node.
1202
1203 Args:
1204 module: Must be module id of the module that defines 'node'
1205
1206 Returns the target name, or None if the node is not a valid target in the given
1207 module (for example, if it's actually defined in another module).
1208 """
1209 if isinstance(node, MypyFile):
1210 if module != node.fullname:
1211 # Actually a reference to another module -- likely a stale dependency.
1212 return None
1213 return module
1214 else: # OverloadedFuncDef or FuncDef
1215 if node.info:
1216 return f"{node.info.fullname}.{node.name}"
1217 else:
1218 return f"{module}.{node.name}"
1219
1220
1221if sys.platform != "win32":

Callers 1

reprocess_nodesFunction · 0.85

Calls 1

isinstanceFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…