Menu

#1373 Explicit relative import marked as error

open
Editor (491)
5
2011-08-24
2011-08-24
Brendon
No

The following import is being marked as an error even though the code runs OK:

from .data.myusers import MyUserEntity

PyDev 2.2.1.2011071313
Eclipse 3.7.0
Windows 7 64-bit

It seems like I'm getting the same problem as in bug ID 3199805, here is the additional information you asked for there, the structure:

src/
__init__.py
data/
__init__.py
myusers.py
service/
__init__.py
users.py

The import line above is in users.py

Discussion

  • Piotr Dobrogost

    Piotr Dobrogost - 2011-08-24

    If it's in users.py it should have been
    from ..data.myusers import (...)
    not
    from .data.myusers import (...)

     
  • Brendon

    Brendon - 2011-08-26

    If I use the extra dot, like so:

    from ..data.myusers import MyUserEntity

    rather than

    from .data.myusers import MyUserEntity

    I get the following error in the console:

    ValueError: Attempted relative import beyond toplevel package