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)?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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)?
You have to ad it at window > preferences> pydev > pydev extensions > code analysis > undefined.
Cheers,
Fabio
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?
Please enter that as a feature request.
Cheers,
Fabio