PyDev appears to be incorrectly parsing a file (with Grammar Version set to 3.0) with the 2.* rules for local imports. I'm posting here to make sure this isn't a known issue; if I get the OK, I'll post an issue in the bug tracker.
To reproduce, set up a project with this relationship:
If foo.py attempts to "import math", PyDev thinks that the interpreter is going to import pkg.math, instead of the built in math module. This is correct in Python 2.*, but is no longer the case in 3.* (see PEP 328 here http://www.python.org/dev/peps/pep-0328/). Because of this error, any uses of the math symbol within foo.py, such getting the .pi attribute, gets tagged with an "Undefined variable from import" error. Auto-completion and go to definition functionality is also broken.
As a fix, when a PyDev project is in 3.0 Grammar mode, it should always use absolute paths in imports except when using the dot syntax (from .math import something).
Thoughts?
-Ryan
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I just encountered this apparently as a consequence of updating to pydev version 2.2.2.2011082312.
I have been using Version 2.2.0.2011062419 for a few months without trouble. It has been good enough for my purposes. I have been searching for an archive site so I could download/update the version that works for well enough for me. I haven't found one yet. Is there such a site?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
PyDev appears to be incorrectly parsing a file (with Grammar Version set to 3.0) with the 2.* rules for local imports. I'm posting here to make sure this isn't a known issue; if I get the OK, I'll post an issue in the bug tracker.
To reproduce, set up a project with this relationship:
main.py
pkg (folder)
-> __init__.py
-> foo.py (Contains:
import math
print(math.pi)
)
-> math.py (empty file)
If foo.py attempts to "import math", PyDev thinks that the interpreter is going to import pkg.math, instead of the built in math module. This is correct in Python 2.*, but is no longer the case in 3.* (see PEP 328 here http://www.python.org/dev/peps/pep-0328/). Because of this error, any uses of the math symbol within foo.py, such getting the .pi attribute, gets tagged with an "Undefined variable from import" error. Auto-completion and go to definition functionality is also broken.
As a fix, when a PyDev project is in 3.0 Grammar mode, it should always use absolute paths in imports except when using the dot syntax (from .math import something).
Thoughts?
-Ryan
Yeap, seems like a bug to me. Please report it in the bugtracker (you can reference this thread if you want).
Cheers,
Fabio
I just encountered this apparently as a consequence of updating to pydev version 2.2.2.2011082312.
I have been using Version 2.2.0.2011062419 for a few months without trouble. It has been good enough for my purposes. I have been searching for an archive site so I could download/update the version that works for well enough for me. I haven't found one yet. Is there such a site?
The update site (http://pydev.org/updates) has archives (in the install dialog you have an option to show old versions).
Cheers,
Fabio
I never had to use the archives before now, which says a lot.
Thanks,
-m
Just to note, I'm working on this issue now, so, if you wait until tomorrow, there should be a nightly build with this fixed.
Cheers,
Fabio