* 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)
| 4014 | * answer, as before. |
| 4015 | */ |
| 4016 | function pythonPackageBinds(imp: ImportMapping, fromFile: string, context: ResolutionContext): boolean { |
| 4017 | if (imp.isNamespace || imp.exportedName === '*') return false; |
| 4018 | const packageFile = resolveImportPath(imp.source, fromFile, 'python', context); |
| 4019 | if (!packageFile || !/(?:^|\/)__init__\.py$/.test(packageFile)) return false; |
| 4020 | return ( |
| 4021 | findExportedSymbol( |
| 4022 | packageFile, |
| 4023 | { isDefault: false, isNamespace: false, exportedName: imp.exportedName, memberName: null }, |
| 4024 | 'python', |
| 4025 | context, |
| 4026 | new Set() |
| 4027 | ) !== undefined |
| 4028 | ); |
| 4029 | } |
| 4030 | |
| 4031 | /** |
| 4032 | * Resolve a whole-MODULE import to that module's file (a file→file dependency). |
no test coverage detected