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

Function overloadSpellings

src/resolution/python-overloads.ts:77–88  ·  view source on GitHub ↗

* How a file can write typing's `overload` as a decorator: bare names (`overload`, * or the alias of `from typing import overload as ov`) and the names a typing * module goes by (`typing`, or `t` after `import typing as t`). A bare * `overload` the file imports from another module is that module'

(filePath: string, context: ResolutionContext)

Source from the content-addressed store, hash-verified

75 * `overload` the file imports from another module is that module's.
76 */
77function overloadSpellings(filePath: string, context: ResolutionContext): { bare: Set<string>; modules: Set<string> } {
78 const imports = context.getImportMappings(filePath, 'python');
79 const bare = new Set<string>();
80 const modules = new Set(TYPING);
81 for (const m of imports) {
82 if (m.isNamespace && TYPING.has(m.source)) modules.add(m.localName);
83 else if (!m.isNamespace && m.exportedName === 'overload' && TYPING.has(m.source)) bare.add(m.localName);
84 }
85 // Not imported by name at all (`from typing import *`): the bare name is typing's.
86 if (!imports.some((m) => m.localName === 'overload')) bare.add('overload');
87 return { bare, modules };
88}
89
90/** Whether the decorators above a `def` hold typing's `overload`. */
91function isOverloadStub(def: Node, lines: string[], overload: { bare: Set<string>; modules: Set<string> }): boolean {

Callers 1

implementationOfFunction · 0.85

Calls 3

getImportMappingsMethod · 0.80
hasMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected