bblfsh / python-driver

GNU General Public License v3.0
10 stars 16 forks source link

Prepending .. in relative imports #213

Open ncordon opened 5 years ago

ncordon commented 5 years ago

Currently, for from .some import relative, we get a node with ..:

relative

And for from ..some import relative, we get two nodes with ..:

relativex2

It may be related to this line

ncordon commented 5 years ago

HT @smacker and @kuba--

r0mainK commented 4 years ago

@ncordon isn't that accurate though ?

from .some import relative

Means relative is in the some file that is in the same directory as the current file. Whereas with:

from ..some import relative

Means relative is in the some file that is in the parent directory of the directory containing the current file. So it makes sense that the first would have one .. node, and the second two ?

smacker commented 4 years ago

All single dots are returned as double dots right now but splitting happens correctly. As a workaround, you can just post-process bblfsh results by replacing .. with . to get the right relative path. (at least it worked for all cases I had):

Screenshot 2019-09-27 at 12 02 52
r0mainK commented 4 years ago

Yeah I did the same, and I'd say the double dot makes more sense to me then a single one, as if you were in the file and wanted to go to the import, you would move around doing cd ../../some etc.