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

Function pythonImportNamesFor

src/resolution/module-importers.ts:826–836  ·  view source on GitHub ↗

* The import names that can denote the module at `modulePath`: its trailing * dotted paths (`models`, `shop.models`), each also behind one dot or more * (`.models`, `..shop.models`), and the dots alone (`.`, `..`), which name a * package by where the importer sits.

(modulePath: string)

Source from the content-addressed store, hash-verified

824 * package by where the importer sits.
825 */
826function pythonImportNamesFor(modulePath: string): string[] {
827 const segments = modulePath.split('/');
828 const absolute = segments.map((_, i) => segments.slice(i).join('.'));
829 const names = new Set<string>(absolute);
830 for (let dots = 1; dots <= MAX_RELATIVE_DOTS; dots++) {
831 const prefix = '.'.repeat(dots);
832 names.add(prefix);
833 for (const name of absolute) names.add(prefix + name);
834 }
835 return [...names];
836}

Callers 1

indexFunction · 0.85

Calls 3

mapMethod · 0.80
joinMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected