* Whether `from P import N` binds something `P/__init__.py` defines or * re-exports, rather than the submodule `P.N`. CPython's `_handle_fromlist` * looks `N` up as an attribute of the package first and imports the * submodule only when the package has no such attribute — so a def, a * constant
(imp: ImportMapping, fromFile: string, context: ResolutionContext)
| 4262 | * answer, as before. |
| 4263 | */ |
| 4264 | function pythonPackageBinds(imp: ImportMapping, fromFile: string, context: ResolutionContext): boolean { |
| 4265 | if (imp.isNamespace || imp.exportedName === '*') return false; |
| 4266 | const packageFile = resolveImportPath(imp.source, fromFile, 'python', context); |
| 4267 | if (!packageFile || !/(?:^|\/)__init__\.py$/.test(packageFile)) return false; |
| 4268 | return ( |
| 4269 | findExportedSymbol( |
| 4270 | packageFile, |
| 4271 | { isDefault: false, isNamespace: false, exportedName: imp.exportedName, memberName: null }, |
| 4272 | 'python', |
| 4273 | context, |
| 4274 | new Set() |
| 4275 | ) !== undefined |
| 4276 | ); |
| 4277 | } |
| 4278 | |
| 4279 | /** |
| 4280 | * Resolve a whole-MODULE import to that module's file (a file→file dependency). |
no test coverage detected