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)
| 1198 | |
| 1199 | |
| 1200 | def 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 | |
| 1221 | if sys.platform != "win32": |
no test coverage detected
searching dependent graphs…