PTVS
PTVS copied to clipboard
Python Intellisense squiggles VisualStudio2022
This issue has been moved from a ticket on Developer Community.
[severity:It's more difficult to complete my work] I am using Visual Studio Community 2022 (64-bit) - Version 17.3.3 (current as of August 2022) to develop a tkinter Python GUI application. I am using a virtual environment with Python 3.10.
Intellisense is giving me fits and is next to useless!!! However, the application runs as I expect it to and is able to import all the referenced modules.
It shows me green squiggles under the module name for imported modules. some are for pip installed packages and some are for modules in other folders in my project.
One example is that I have a BusinessObjects folder in my project that contains a module named AppSettings.py. AppSettings.py contans an ApplicationSettings class definition. The BusinessObjects folder is in the Search Paths for the project.
When I reference the ApplicationSettings class from a module in a different folder I use the following import statement:
from AppSettings import ApplicationSettings
I get green squiggles under AppSettings and hence get no Intellisense for the ApplicationSettings class. The warning is reportMissingImports.
If I change the import statement to ..BusinessObjects.AppSettings import ApplicationSettings the warning goes away and Intellisense appears to function normally.
It appears that Intellisense is not using the Search Paths as I expect it to.
In another case I pip installed a package named PyPubSub (4.0.3) into my virtual environment.
I import it with "from pubsub import pub". 'pubsub' shows a reportMissingImports warning and I get no intellisense help with method name completion.
Even adding the site-packages folder to the search path does not provide a workaround for this instance.
Sometimes I am able to temporarily eliminate the issues by deleting the filelist.bin file under .vs\PyAstroDevices\v17 folder, but sometimes it has no effect.
It seems as though there have been many many similar reports going back for several years, without any comprehensive permanent fixes. Please look into this and fnally fix this longstanding annoyance!
Original Comments
Feedback Bot on 8/31/2022, 05:54 PM:
(private comment, text removed)
Original Solutions
(no solutions)
@bschnurr Do you know if it's relevant to #6713?😊Seems like we already have a fix for that.
I have the same problem, imported torch is all missing imports. However, I have noticed this: when I start fresh instance of Visual Studio 2022, all is working correctly. However, when I start debug of the application and finish it, Intellisense is broken after that.
Hello, are you able to provide a code sample so we can have an easy repro to investigate?
It is not related to some specific code, any Python code with imports from external 3rd party lib (installed via pip or Conda) or my own imports (relative or absolute path) is broken. The only working Intellisense is for Python native libs.
@MartinPerry Ok thank you, I will try to repro locally and figure out what's going on :)
The issue with imports from external third party library should have been fixed, see https://github.com/microsoft/PTVS/issues/6713.
I just ran into this, and stumbled on this error report. Might be the wrong place but - I had the exact same problems, but with some fairly standard libraries. It started complaining about syntax and things got weird.
import csv, codecs
from enum import Enum, IntEnum, auto
import datetime
I ran it through Black, reloaded the editor. Still had problems.
I went to duplicate the error with a minimal example.
No problem.
I closed my source file, and reopened it.
The thing parsed properly, no errors at all.
So I think there is a spurious error floating around in here; like all good uninitialized variables in code, it'll manifest itself in different repeatable ways.