(filePath: string)
| 148 | * the same keys. |
| 149 | */ |
| 150 | export function moduleReferenceKeys(filePath: string): string[] { |
| 151 | const keys = importPathKeys(filePath); |
| 152 | // A Python package's `__init__.py` is a submodule of the package above it, |
| 153 | // as a module file beside it is through its folder: `app/pkg/sub/__init__.py` |
| 154 | // is what `from app.pkg import sub as s`, parked as 'module:pkg', imports. |
| 155 | const parts = filePath.split('/'); |
| 156 | const above = parts.length >= 3 && parts[parts.length - 1] === '__init__.py' ? parts[parts.length - 3]! : ''; |
| 157 | if (above && !keys.includes(above)) keys.push(above); |
| 158 | return keys.map((key) => MODULE_KEY + key); |
| 159 | } |
no test coverage detected