#1387 Undefined variable from Import issue with class constants

pending
Editor (491)
5
2011-09-14
2011-09-13
No

I'm using aptana for python development. I have no issue with my python path config, autocomplete works fine with everything, and code analysis seems fine apart from the following problem:

When I have a "constant" in one of my classes and I try to access it, eclipse complains about "undefined variable from import" on the constant, eg

class Universe(object):
ULTIMATE_ANSWER = 42

''' In another file '''
import Universe
print Universe.ULTIMATE_ANSWER

where Universe.ULTIMATE_ANSWER triggers the error. Additionally, autocomplete works fine, so when I type Universe.x I do get all the constants proposed.
It only seems to happen when I import a module, if I happen to do it within the same file then there doesn't seem to be an issue.

It's not an urgent issue, however it tends to become annoying, and might make you ignore actual errors.

System details:
Os: Ubuntu 11.04
Aptana Studio 3, build: 3.0.4.201108101506
Pydev: 2.2.1.2011073123

I can also replicate this in Eclipse Indigo 3.7

Discussion

  • Eleni Lixourioti

    Clarification:
    This is just example code, so it would be more appropriate to write something like
    from bigbang.models import Universe
    as in import statement
    The actual code is too long to be included, but this is easily replicable.

     
  • Fabio Zadrozny

    Fabio Zadrozny - 2011-09-14

    Ok, I'm trying to reproduce it here without success.

    I think it's something related to the structure of the code (i.e.: maybe some internal class or relative import or some other conjunction).

    If this code is open source, can you point me to it so that I can take a look at the actual structure?

    If not, can you try to isolate the problem in a project to attach to this bug? I.e.: create the 2 modules and do the structure that leads to that error. Probably just exposing how the Line class is constructed and the package structure for it should be enough...

     
  • Fabio Zadrozny

    Fabio Zadrozny - 2011-09-14
    • status: open --> pending
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks