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

Function resolvePythonAbsoluteModule

src/resolution/import-resolver.ts:3972–3987  ·  view source on GitHub ↗

* Resolve a Python dotted module import (`import a.b.c`, `from .a.b import x`) to its file — * the Django `AppConfig.ready(): import myapp.signals` pattern and any * side-effect module import.

(
  ref: UnresolvedRef,
  context: ResolutionContext
)

Source from the content-addressed store, hash-verified

3970 * side-effect module import.
3971 */
3972function resolvePythonAbsoluteModule(
3973 ref: UnresolvedRef,
3974 context: ResolutionContext
3975): ResolvedRef | null {
3976 if (ref.referenceKind !== 'imports') return null;
3977 // Only a DOTTED `import a.b.c` ref carries its full module path, and so does
3978 // the module a from-import names, dotted or not: `from loader import X` is
3979 // the top-level `loader`, found from the package roots as `import loader`
3980 // finds it. A bare leaf it imports (`from app.api.routes import
3981 // authentication`) is ambiguous on its own — three `authentication.py` files
3982 // may exist — so leave it to resolveModuleImportToFile, which uses the
3983 // import's source (`app.api.routes`) to build the full path.
3984 if (!ref.referenceName.includes('.') && !isPythonFromImportModule(ref, context)) return null;
3985 const hit = pythonModuleFileNode(ref.referenceName, ref.filePath, context);
3986 return hit ? { original: ref, targetNodeId: hit.id, confidence: 0.9, resolvedBy: 'import' } : null;
3987}
3988
3989/**
3990 * Resolve a Rust qualified reference `A::B::C` to the item module `A::B`

Callers 1

resolveViaImportFunction · 0.85

Calls 1

pythonModuleFileNodeFunction · 0.85

Tested by

no test coverage detected