Code Completion does not show all options for installed package

Answered

Hello, I have a bit trouble with the auto completion of PyCharm 2018.2.3 (OS: Ubuntu 16.04). In my current project I want to use the vtk Package (Visualization ToolKit) with Python3.6. Therefore I created a new interpreter (virtual environment) and installed the package (version 8.1.1) which worked just fine. However the auto completion does not show all available options. For example, the functions [mapperObject].SetInputConnection(), [sourceObject].GetOutputPort()] and [actorObject].SetMapper() are not displayed in the code completion. In spite of that, calling them works very well. I can execute the code without any problems. Nonetheless, I very much would like to know why this doesn't work as expected, just in case that I encounter this problem again.

Kind regards

3 comments

According to this thread on StackOveflow it seems like PyCharm can't suggest options because the type of the object is only known at runtime. That somehow makes sense. Are you planning to add maybe in future some kind of static analysis for object types?

0

Hi hailToThePythonGod,

Thank you for contacting PyCharm support.

As far as we informed we are currently not planning to add such feature.

As a workaround you could try using typing package to define the type of an object. Something like this example:

from typing import Dict
from vtk import vtkTextureMapToSphere


my_dict: Dict[str, vtkTextureMapToSphere] = []

my_dict['1']. (here, when you type '.'(dot) you will see the hints)

Kind regards,

Sergey

https://www.jetbrains.com

The Drive to Develop

0

Hello Sergey Karpov, thank you for your helpful answer! I will take a look at the typing package.

0

Please sign in to leave a comment.