Unexpected auto-completer behavior when working with aiida
Hi,
I use wing to test the aiida-core package with the code given here: https://aiida-tutorials.readthedocs.i.... The code snippets are the following:
from aiida import load_profile
load_profile()
from aiida.orm import Code, Computer, Data, Node, Float, Str
from aiida.plugins import CalculationFactory, DataFactory
from aiida.engine import calcfunction
In the above code, the calcfunction
only exists in aiida.engine, so it should be imported like this:
from aiida.engine import calcfunction
But when I type the following:
from aiida.orm import c<tab>
then the auto-completer of wing will still suggest the name of calcfunction
as one of the candidates, which if I selected and input there, the code will be error and finally fail to run.
Any hints for this problem?
Regards
Comments
What happens if you complete the completion and do goto-definition on calcfunction on the 'from aiida.orm import' line? This might be a result of orm importing calcfunction internally in some way, or the symbol being listed in a *.pyi file if there are any, but then having other import behavior at runtime. Looking at where Wing ends up after goto-definition is the first step to figuring this out.
Both of the two imports will skip to the same location here: https://github.com/aiidateam/aiida-co...
Another differences I noted that is when importing by 'from aiida.orm import' the result of the completion will becomes 'calcfunction(function)', while the completion result for the 'from aiida.engine import' line is 'calcfunction'.
Still cannot figure out the reason.
Regards
What is the code error when you try to run it? I'm guessing maybe a circular import problem.
See the following: