Hi,
See here for my full discussions with the Wingware Support group:
https://ask.wingware.com/question/1777/unexpected-auto-completer-behavior-when-working-with-aiida/?answer=1796#post-id-1796
Here are the comment excerpted from there given by the Wingware Support group:
--------------
OK, based on setting this up here I've got the explanation.
The short answer is that aiida implements an import hook that has
behavior that does not match what Python itself does when it processes
imports, and this is combining with some poor naming choices and
overuse of 'from x import *' to make you think you're being offered
the function calcfunction when in fact it would normally be importing
the module aiida-core/orm/nodes/process/calculation/calcfunction.py
through a long chain of 'from x import *'s.
The details:
The reason we're offering calcfunction in the completer for aiida.orm
is because of the following import chain:
orm/__init__.py has from .nodes import *
orm/nodes/__init__.py has from .process import *
orm/nodes/process/__init__.py has from .calculation import *
orm/nodes/process/calculation/__init__.py has from .calcfunction
import CalcFunctionNode
This imports from orm/nodes/process/calculation/calcfunction.py
Indeed, calcfunction is defined also at runtime if I stop in the
debugger after that import in
aiida/orm/nodes/process/calculation/__init__.py but module loading in
aiida is completely dynamic and it appears that its module load it's
not processing the import * in such a way that 'calcfunction' is
defined in the places that did the imports. CalcFunctionNode is
defined but not calcfunction. This clearly does not match what Python
normally does with imports. It would also import the symbol
calcfunction through the import *.
Goto-definition was presumably going to the like-named calcfunction
function definition because WIng was also seeing the second correct
import 'from aiida.engine import calcfunction' and finding it that
way. In fact calcfunction could be either that or the imported module
as described above, except of course that aiida has implemented
non-standard module loading. Indeed if I have code like the following,
Wing's Source Assistant shows that calcfunction could either be a
module or a function:
from aiida.engine import calcfunction
from aiida.orm import calcfunction
There's nothing we can do about this. If someone decides to change
module load behavior at runtime there's no way for us to know that.
Essentially, they're inventing a different programming language.
--------------
Regards
--
Hongyi Zhao <
hongy...@gmail.com>