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

Function pythonImportNamesFor

src/resolution/module-importers.ts:941–951  ·  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

939 * package by where the importer sits.
940 */
941function pythonImportNamesFor(modulePath: string): string[] {
942 const segments = modulePath.split('/');
943 const absolute = segments.map((_, i) => segments.slice(i).join('.'));
944 const names = new Set<string>(absolute);
945 for (let dots = 1; dots <= MAX_RELATIVE_DOTS; dots++) {
946 const prefix = '.'.repeat(dots);
947 names.add(prefix);
948 for (const name of absolute) names.add(prefix + name);
949 }
950 return [...names];
951}

Callers 1

indexFunction · 0.85

Calls 3

mapMethod · 0.80
joinMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected