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

Function overloadSpellings

src/resolution/python-overloads.ts:78–89  ·  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

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