PTVS icon indicating copy to clipboard operation
PTVS copied to clipboard

IntelliSense for Search Paths doesn't work when import folder outside the workspace.

Open linette-zyy opened this issue 1 year ago • 6 comments

Environment image

Steps to Reproduce

  1. Open a folder as workspace in SE.
  2. Add new python file in SE named WholsRunningMe.py.
  3. Select a python environment from the python toolbar to open PythonSettings.json and you can check “Show All Files” on the toolbar to reveal local settings.
  4. Create a folder named folder1 in your local, such like : C:\Users\vyizh12\source\repos\python-azure-web-app-cookiecutter\folder1
  5. Add init.py in folder1 and type some code in __init__.py def FOLDER1_MSG(): print("hello world!")
  6. Add searchpaths in PythonSettings.json. image
  7. Type code below in WholsRunningMe.py
import folder1
folder1.FOLDER1_MSG()
  1. Make sure IntelliSense should show squiggles on the import statement

Expected behavior Make sure IntelliSense should show when import statement

Additional context and screenshots No IntelliSense when import folder1 image

linette-zyy avatar Feb 17 '24 09:02 linette-zyy

This also repros with project view scenarios. Adding the path to Tools -> Options -> Python -> Analysis -> Search Paths doesn't resolve the imports. Pylance logs show Info: Un-registering request handler for 3dad9764-9666-4d1e-b1c2-35f267fcf494 failed., might be an indication of what goes wrong.

I can also repro this with last pylance stable(2023.12.1), which indicates this bug is not a regression and has been there for a while.

StellaHuang95 avatar Feb 20 '24 18:02 StellaHuang95

@linette-zyy How did you find PythonSettings.json in folder view? I don't see it.

StellaHuang95 avatar Feb 20 '24 19:02 StellaHuang95

@StellaHuang95 PythonSettings

linette-zyy avatar Feb 21 '24 07:02 linette-zyy

This issue also repro on “Add folder to SearchPath” on today's build image

image No IntelliSense after add folder to SearchPath image

linette-zyy avatar Feb 21 '24 08:02 linette-zyy

On today's build image The module with green wavy lines after import. image

linette-zyy avatar Jul 17 '24 07:07 linette-zyy

On today's build, image After add new item "module1.py", no IntelliSence when inport image

linette-zyy avatar Jul 18 '24 06:07 linette-zyy