* 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 )
| 4171 | * side-effect module import. |
| 4172 | */ |
| 4173 | function resolvePythonAbsoluteModule( |
| 4174 | ref: UnresolvedRef, |
| 4175 | context: ResolutionContext |
| 4176 | ): ResolvedRef | null { |
| 4177 | if (ref.referenceKind !== 'imports') return null; |
| 4178 | // Only a DOTTED `import a.b.c` ref carries its full module path, and so does |
| 4179 | // the module a from-import names, dotted or not: `from loader import X` is |
| 4180 | // the top-level `loader`, found from the package roots as `import loader` |
| 4181 | // finds it. A bare leaf it imports (`from app.api.routes import |
| 4182 | // authentication`) is ambiguous on its own — three `authentication.py` files |
| 4183 | // may exist — so leave it to resolveModuleImportToFile, which uses the |
| 4184 | // import's source (`app.api.routes`) to build the full path. |
| 4185 | if (!ref.referenceName.includes('.') && !isPythonFromImportModule(ref, context)) return null; |
| 4186 | const hit = pythonModuleFileNode(ref.referenceName, ref.filePath, context); |
| 4187 | return hit ? { original: ref, targetNodeId: hit.id, confidence: 0.9, resolvedBy: 'import' } : null; |
| 4188 | } |
| 4189 | |
| 4190 | /** |
| 4191 | * Resolve a Rust qualified reference `A::B::C` to the item module `A::B` |
no test coverage detected