Skip to content
This repository has been archived by the owner on Mar 8, 2020. It is now read-only.

Prepending .. in relative imports #213

Open
ncordon opened this issue Sep 10, 2019 · 4 comments
Open

Prepending .. in relative imports #213

ncordon opened this issue Sep 10, 2019 · 4 comments
Labels

Comments

@ncordon
Copy link
Member

ncordon commented Sep 10, 2019

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 ncordon added the bug label Sep 10, 2019
@ncordon
Copy link
Member Author

ncordon commented Sep 10, 2019

HT @smacker and @kuba--

@r0mainK
Copy link

r0mainK commented Sep 27, 2019

@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
Copy link
Contributor

smacker commented Sep 27, 2019

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
Copy link

r0mainK commented Sep 27, 2019

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants