* 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 )
| 4418 | * side-effect module import. |
| 4419 | */ |
| 4420 | function resolvePythonAbsoluteModule( |
| 4421 | ref: UnresolvedRef, |
| 4422 | context: ResolutionContext |
| 4423 | ): ResolvedRef | null { |
| 4424 | if (ref.referenceKind !== 'imports') return null; |
| 4425 | // Only a DOTTED `import a.b.c` ref carries its full module path, and so does |
| 4426 | // the module a from-import names, dotted or not: `from loader import X` is |
| 4427 | // the top-level `loader`, found from the package roots as `import loader` |
| 4428 | // finds it. A bare leaf it imports (`from app.api.routes import |
| 4429 | // authentication`) is ambiguous on its own — three `authentication.py` files |
| 4430 | // may exist — so leave it to resolveModuleImportToFile, which uses the |
| 4431 | // import's source (`app.api.routes`) to build the full path. |
| 4432 | if (!ref.referenceName.includes('.') && !isPythonFromImportModule(ref, context)) return null; |
| 4433 | const hit = pythonModuleFileNode(ref.referenceName, ref.filePath, context); |
| 4434 | return hit ? { original: ref, targetNodeId: hit.id, confidence: 0.9, resolvedBy: 'import' } : null; |
| 4435 | } |
| 4436 | |
| 4437 | /** |
| 4438 | * Resolve a Rust qualified reference `A::B::C` to the item module `A::B` |
no test coverage detected