Open webknjaz opened 6 years ago
Ok, I guess there's no support for double dots. Are there more than 2 dots in Python relative imports anywhere?
Short answer is yes, it's been copied from the working code.
One can import from higher-level packages provided that the current package is not the root. This can depend on PYTHONPATH
and __init__.py
.
Oh, I misread your question :)
No, three dots is not supported. It's like in relative paths in fs: two dots is a parent dir, single dot is current dir.
Looking at https://github.com/fiatjaf/module-linker/blob/d8e2601/languages/python.js#L62-L80 I'd say it should support two dots, meaning there's a bug somewhere. I've checked that regexps above work well.
Also, this https://github.com/fiatjaf/module-linker/blob/d8e2601/languages/python.js#L36-L39 condition looks invalid: it's never true, the code checks that the string is both empty and starts with a dot.
Thank you very much for the effort, @webknjaz. I'm a little embarrassed by that never-true condition, but anyway, I'll try to fix this as soon as possible.
Consider this code:
Module Linker creates references to:
instead of referring upper-level packages/modules.
However it successfully recognises same-package imports, like: