Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

Code Analysis and Globals

2009-08-31
2013-03-15
  • Nicolas Keller
    Nicolas Keller
    2009-08-31

    I have a python project where some globals are set when the program starts. How can I teach pydev's source code analysis that these globals are set in my project even when they are not set in the current source file?

    I see that I can set forced builtins - but if I add my global objects there, they are recognized by code completion but still produce errors in code analysis. Did I misunderstood forced builtins? Let me give you a short example:

    First File (called first):

    class DEMO:
        pass
    import __builtin__
    __builtin__.__dict__['DEMO'] = DEMO

    Second file (called later):
    ...
    demo = DEMO()

    How can I tell pydevs source code analysis that DEMO exists as a global in the current project and where to look for DEMO (without an actual import statement in the second file)?

     
    • Fabio Zadrozny
      Fabio Zadrozny
      2009-08-31

      You have to ad it at window > preferences> pydev > pydev extensions > code analysis > undefined.

      Cheers,

      Fabio

       
  • Nicolas Keller
    Nicolas Keller
    2009-09-25

    Hi Fabio, thank you for the quick response. Your solution works, but it's a little bit ugly, because I have lots of these globals and just in one project. Could you consider an option defining this by project or even an option to keep this globals in an external file / structure?

     
  • Fabio Zadrozny
    Fabio Zadrozny
    2009-09-29

    Please enter that as a feature request.

    Cheers,

    Fabio