MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / isPythonProjectModule

Method isPythonProjectModule

src/resolution/index.ts:2296–2313  ·  view source on GitHub ↗

* True when `receiver` is a local name bound by an import that resolves to a * file IN THIS PROJECT — the only case where letting a python * built-in-method name through the filter is safe (#1681). * * Asking only whether SOME import bound the local name is not enough: every * import

(ref: UnresolvedRef, receiver: string)

Source from the content-addressed store, hash-verified

2294 * serve; anything else stays a silent miss rather than a wrong edge.
2295 */
2296 private isPythonProjectModule(ref: UnresolvedRef, receiver: string): boolean {
2297 for (const imp of this.context.getImportMappings(ref.filePath, ref.language)) {
2298 if (imp.localName !== receiver) continue;
2299 // `import pkg.mod` / `import pkg.mod as m` binds the module `source`
2300 // names. `from pkg import mod` binds `pkg.mod`, and `from . import mod`
2301 // binds `.mod` — join without doubling the dot that makes `.` mean the
2302 // current package.
2303 const specifier = imp.isNamespace
2304 ? imp.source
2305 : imp.source.endsWith('.')
2306 ? `${imp.source}${imp.exportedName}`
2307 : `${imp.source}.${imp.exportedName}`;
2308 if (resolveImportPath(specifier, ref.filePath, ref.language!, this.context)) {
2309 return true;
2310 }
2311 }
2312 return false;
2313 }
2314
2315 /**
2316 * Check if reference is to a built-in or external symbol

Callers 1

isBuiltInOrExternalMethod · 0.95

Calls 2

resolveImportPathFunction · 0.90
getImportMappingsMethod · 0.80

Tested by

no test coverage detected