Auto complete does not always add the import statement
Hi,
This is a hard problem to pinpoint because I am not able to reproduce it in simple test projects.
Since pycharm 2018, there are random instances where the auto complete suggests a given class or function. When you select the option, the auto complete works, but no import statement is added to the file.
For example, say you want to use Dict from the typing module. You start typing "Dic" and hit control space. The first suggestion is Dict (typing). You hit enter and the line is completed to Dict. But no import statement is added.
The IDE underlines "Dict" in red because it does not know where it comes from. If you use the red bulb, the first option is to import Dict from typing. If you hit enter on that option, it imports the symbol properly.
Dict is just an example. It will sometimes import flawlessly or require to use the red bulb. It does that with built in modules, installed modules and local modules. Note that when it refuses to import a given symbol with auto-complete, it will never work. You have to use to red bulb. The same symbol may work in another file of the same project.
I know my coworker also has that problem. Since I am not able to reproduce the bug reliably in simple project, there is chance that this is related to our project. Note that we do not share idea files, only python source files. We do use a lot of remote deployment and remote interpreters.
I wasn't able to find a community post or a ticket in utrack related to this. So I was wondering if we are alone or anyone else is having this issue?
Thanks!
Please sign in to leave a comment.
I am the co-worker, I would like to add that we saw this issue happen on Windows and OSX.
Thank you!
Hi Olivier and Kevin,
Thank you for contacting PyCharm support.
Have you tried File > Invalidate Caches/Restart > Invalidate and Restart? If not then please do and then check if the issue reoccurs.
If doesn't work, could you share a code sample where you had problems so we can try to reproduce?
Please also clarify what is your PyCharm version.
Looking forward to your reply.
Kind regards,
Sergey
https://www.jetbrains.com
The Drive to Develop
Hi Sergey, thanks for the quick reply!
Invalidating the cache does not fix the problem on windows for me.
Here is my PyCharm version:
PyCharm 2018.2.4 (Professional Edition)
Build #PY-182.4505.26, built on September 19, 2018
JRE: 1.8.0_152-release-1248-b8 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0
As I state above, I am not able to reproduce the problem in test projects. This only appears to be happening in large projects which I cannot share. Here is a small redacted example that reproduces the problem for me:
In the above example, using control space after t1: Dict reproduces the problem. I'm sorry I don't have something more tangible.
That's why I wrote a community post to see if others had seen similar problems.
Thanks
Hi, thank you for the report. Ctrl+Space should not really suggest anything here as long as you don't use Ctrl+Space Space which is a shortcut for a project-wide completion. Or did I miss the usecase? Do you have any custom plugins installed?
You are correct that I do control space space. I always resumed that to control space, but I should have been clearer.
So, to be crystal clear: When I do control space, I see no suggestions which is expected. When press space again, the problem that I describe occurs.
Thanks
Thanks for the clarification.
So, do you have any custom plugins installed?
Kind regards,
Sergey
I'm sorry, I missed your last question. I do not have any custom plugins for PyCharm.
Thanks
Hi Olivier,
Sorry for a delay in reply.
Please reproduce the problem and then upload you logs folder zipped (Help | Show Log in...) to https://uploads.services.jetbrains.com/ and let us know the name of the zip file.
No problem for the delay, the next time this happens, I will upload the logs and update you here.
Thanks
It happened again today at about 11h40 EDT. I uploaded the logs with the name log - Auto complete does not always add the import statement.zip.
It happened with this code:
Hitting enter did nothing:
However, this works:
Thanks
Hi,
Please clarify if you are trying to do it while PyCharm is updating indices or anything like that?
We couldn't reproduce it on our side.
There is no process running while I do this (progress bars at the bottom of PyCharm).
As I said, it is a sporadic problem, I did not encounter the problem between October 12th up to the 19th. Also to reiterate, we are using remote deployments and interpreters, so it may play into the problem.
Thanks for trying
I have filed an issue to our issue tracker https://youtrack.jetbrains.com/issue/PY-32349, please follow it for updates.
See https://intellij-support.jetbrains.com/hc/en-us/articles/207241135-How-to-follow-YouTrack-issues-and-receive-notifications if you are not familiar with YouTrack.
Alright thanks. Sorry I don't have more to go on.