Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

codeintel2: Python: Fixes relative imports #14

Closed
wants to merge 1 commit into from

Conversation

Kronuz
Copy link

@Kronuz Kronuz commented Feb 14, 2015

Relative improts where always based on the main buffer's path.
Instead, use current relative path (if there is one) for relative
imports.

Fixes the case where a module module.first imports module.first.some
by using relative import import .some and the current buffer's path
is not in module/first.

Relative improts where always based on the main buffer's path.
Instead, use current relative path (if there is one) for relative
imports.

Fixes the case where a module `module.first` imports `module.first.some`
by using relative import `import .some` and the current buffer's path
is not in `module/first`.
@Naatan Naatan added this to the 9.2 milestone May 21, 2015
@Naatan Naatan modified the milestones: 9.3, 9.2 Aug 6, 2015
@Naatan
Copy link
Member

Naatan commented Feb 8, 2016

@Kronuz, any chance you could elaborate on this PR?

@belonesox
Copy link

As far as I understand, in Python it is illegal to use a relative import to refer to modules located in a different directory on the filesystem.

It is not true.
https://www.python.org/dev/peps/pep-0328/

«from ...xxx import yyy» syntax works for Python 2 and Python 3, and even supported by pylint checker.

@mitchell-as mitchell-as modified the milestones: 9.3.3, 9.3 Mar 21, 2016
@mitchell-as mitchell-as self-assigned this Mar 21, 2016
@Naatan Naatan modified the milestones: 10.0, 9.3.3 Mar 21, 2016
@mitchell-as
Copy link
Contributor

I never said from ...xxx import yyy is invalid Python, but that import .whatever is. (Your link verifies my assertion.) I still do not have enough information to write a test case for this PR. If my earlier question is not clear, please ask me where to elaborate.

@belonesox
Copy link

Yes, «import .whatever» is invalid, but I was asked to comment «in Python it is illegal to use a relative import to refer to modules located in a different directory on the filesystem»
in issue #1175 because «from .somewhere import something» is also «relative import».

@mitchell-as
Copy link
Contributor

Yes, that's fair. When taken out of this PR's context, the sentence you quoted can be false under most interpretations.

@mitchell-as
Copy link
Contributor

Closing this, as we cannot commit it without a proper test case, and there has been no response for over a year and a half.

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

Successfully merging this pull request may close these issues.

5 participants