* 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)
| 3813 | * answer, as before. |
| 3814 | */ |
| 3815 | function pythonPackageBinds(imp: ImportMapping, fromFile: string, context: ResolutionContext): boolean { |
| 3816 | if (imp.isNamespace || imp.exportedName === '*') return false; |
| 3817 | const packageFile = resolveImportPath(imp.source, fromFile, 'python', context); |
| 3818 | if (!packageFile || !/(?:^|\/)__init__\.py$/.test(packageFile)) return false; |
| 3819 | return ( |
| 3820 | findExportedSymbol( |
| 3821 | packageFile, |
| 3822 | { isDefault: false, isNamespace: false, exportedName: imp.exportedName, memberName: null }, |
| 3823 | 'python', |
| 3824 | context, |
| 3825 | new Set() |
| 3826 | ) !== undefined |
| 3827 | ); |
| 3828 | } |
| 3829 | |
| 3830 | /** |
| 3831 | * Resolve a whole-MODULE import to that module's file (a file→file dependency). |
no test coverage detected