(source: string, fromFile: string)
| 4999 | * `..forms` → 'app/forms'. Null when its dots climb above the project. |
| 5000 | */ |
| 5001 | export function pythonModulePath(source: string, fromFile: string): string | null { |
| 5002 | const name = source.replace(/^\.+/, ''); |
| 5003 | const dots = source.length - name.length; |
| 5004 | if (dots === 0) return name.replace(/\./g, '/'); |
| 5005 | const modulePath = path.posix.join(path.posix.dirname(fromFile), '../'.repeat(dots - 1), name.replace(/\./g, '/')); |
| 5006 | return modulePath === '..' || modulePath.startsWith('../') ? null : modulePath; |
| 5007 | } |
| 5008 | |
| 5009 | /** |
| 5010 | * The import binding of the type a call's receiver is declared with, read the |
no test coverage detected