PTVS icon indicating copy to clipboard operation
PTVS copied to clipboard

Python Intellisense squiggles VisualStudio2022

Open vsfeedback opened this issue 2 years ago • 1 comments

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)

vsfeedback avatar Sep 07 '22 16:09 vsfeedback

@bschnurr Do you know if it's relevant to #6713?😊Seems like we already have a fix for that.

StellaHuang95 avatar Sep 07 '22 23:09 StellaHuang95

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.

MartinPerry avatar Oct 26 '22 15:10 MartinPerry

Hello, are you able to provide a code sample so we can have an easy repro to investigate?

AdamYoblick avatar Oct 28 '22 21:10 AdamYoblick

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 avatar Oct 29 '22 08:10 MartinPerry

@MartinPerry Ok thank you, I will try to repro locally and figure out what's going on :)

AdamYoblick avatar Oct 29 '22 22:10 AdamYoblick

The issue with imports from external third party library should have been fixed, see https://github.com/microsoft/PTVS/issues/6713.

StellaHuang95 avatar Apr 19 '23 21:04 StellaHuang95

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.

jgwinner avatar Jul 09 '23 20:07 jgwinner