Tab-completion for run-time dynmically loaded modules/packages.

Answered

Hi,

 

I try to run the AiiDA-core python package with the example given https://aiida-tutorials.readthedocs.io/en/latest/_downloads/f061ae1c15c29f058cc28e52d6c50cdd/demo_wannier_calcjob.py.

According to the instructions here: https://aiida.readthedocs.io/projects/aiida-core/en/latest/working_with_aiida/scripting.html#verdi-shell, I can use the ` verdi shell ` command to invoke a ipython shell which can do the completions correctly.

But when I edit the above mentioned script with pycharm, then the corresponding completions will be disabled. Say for the following code snippets:

from aiida import load_profile
load_profile()

from aiida.engine import submit
from aiida.orm import load_node, Code, Dict

code = Code.get_from_string("wannier90-3.1.0-wannier-manual") # REPLACE <CODE LABEL>
# Prepare the builder to launch the calculation
builder = code.get_builder()


All of the builder.* part will not have completion suggestions.

On the other hand, if I put the following heading lines into a startup.py file:

from aiida import load_profile
load_profile()

And then export PYTHONSTARTUP=/path/to/start.py, then run python/ipython, the tab-completion will be enabled.

But how to enable the tab-completion for this case within pycharm?

Any hints for this problem?

Regards

1 comment
Comment actions Permalink

PyCharm uses static code analysis which doesn't allow generating code completion for dynamically generated code.

As you mentioned, it works in the Console, but this is due to the runtime availability where the types of objects are known.

The following ticket may be relevant to your case https://youtrack.jetbrains.com/issue/PY-40588

0

Please sign in to leave a comment.