* 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)
| 75 | * `overload` the file imports from another module is that module's. |
| 76 | */ |
| 77 | function 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`. */ |
| 91 | function isOverloadStub(def: Node, lines: string[], overload: { bare: Set<string>; modules: Set<string> }): boolean { |
no test coverage detected