Bug 322534

Summary: Imports with relative path are not understood correctly
Product: [Developer tools] kdev-python Reporter: Hai Zaar <haizaar>
Component: Language supportAssignee: Sven Brauch <mail>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: 1.4.0 / 1.4.1 (stable)   
Target Milestone: 1.6.0   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: Patch to make relative imports work (for me)

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