Bug 322534 - Imports with relative path are not understood correctly
Summary: Imports with relative path are not understood correctly
Status: RESOLVED FIXED
Alias: None
Product: kdev-python
Classification: Developer tools
Component: Language support (show other bugs)
Version: 1.4.0 / 1.4.1 (stable)
Platform: Other Linux
: NOR normal
Target Milestone: 1.6.0
Assignee: Sven Brauch
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-07-18 15:42 UTC by Hai Zaar
Modified: 2013-08-13 10:28 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
Patch to make relative imports work (for me) (2.88 KB, patch)
2013-08-06 17:44 UTC, Hai Zaar
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Hai Zaar 2013-07-18 15:42:37 UTC
Consider the following dir structure:
p/
      __init__.py
      a.py    # contains line : "class A(object): pass"
      s/
           __init__.py  # contains line "from ..a import A"

When I open "p" directory as a project and then open s/__init__.py, the import of A is not recognized and problems window shows:
    
      Declaration for "__init__.A" not found in the specified module

Obviously importing "p.s" from python and using "p.s.A" works.
        

Reproducible: Always

Steps to Reproduce:
See details




kdev-python version 1.4.2 on Kubuntu 13.04 64-bit
Comment 1 Sven Brauch 2013-07-18 16:02:15 UTC
Yes, known issue, it's on the TODO list already.
Comment 2 Hai Zaar 2013-07-18 16:20:09 UTC
Great. Looking forward to have it! :)
Comment 3 Hai Zaar 2013-08-06 17:44:18 UTC
Created attachment 81589 [details]
Patch to make relative imports work (for me)

How about the attached patch?

BTW, do you usually create unitests for this kind of stuff?
Comment 4 Sven Brauch 2013-08-13 10:28:32 UTC
Git commit e1de00ab8d0544b846fc0b0de3e4a2648b47c13d by Sven Brauch, on behalf of Zaar Hai.
Committed on 13/08/2013 at 10:27.
Pushed by brauch into branch 'master'.

Make relative imports work
REVIEW:111928
CCMAIL:haizaar@haizaar.com

M  +13   -2    duchain/contextbuilder.cpp
M  +4    -1    duchain/declarationbuilder.cpp

http://commits.kde.org/kdev-python/e1de00ab8d0544b846fc0b0de3e4a2648b47c13d