Home > database >  Pylance in VSCode still shows reportMissingImports even after editing python.analysis.extraPaths
Pylance in VSCode still shows reportMissingImports even after editing python.analysis.extraPaths

Time:08-05

I have been breaking my head trying to figure out what I am doing wrong. Hope someone can help me with this. I have a folder in my current working directory in Visual Studio Code 1.69.2 on a Ubuntu 22.04 system with miniconda environments. The folder has some python scripts with functions and classes that I want to use in a jupyter notebook in vscode. I also named the folder in which I have additional python scripts as src. This is what the directory structure looks like.

File Structure

I have the python.analysis.autoSearchPaths to True. So, in principle, the python files in src should be detected automatically. However, PyLance still shows the reportMissingImports error. However, I am able to access the functions and classes in that folder. Additionally, I have also added that path to the python.analysis.extraPaths in the settings

Settings File

However, I still get the Pylance error and I am not sure what I am doing wrong here.

File Error

I will be really grateful if someone could help me out here. Cheers

Edit 1

I have attached screenshots of the exact error being shown enter image description here

And the problem seems to be exclusively with the Jupyter extension in vscode and Pylance is working as expected in a .py file

CodePudding user response:

Please check the error report of the Yellow wavy line.

PyLance still shows the reportMissingImports error. However, I am able to access the functions and classes in that folder. Additionally

I think the error content of the Yellow wavy line should be reportunusedimport.

enter image description here

You can change the following code in your setting.json:

  "python.analysis.diagnosticSeverityOverrides": {
    "reportUnusedImport": "none",
  },

In this way, you will not be warned of unused imports:

enter image description here

CodePudding user response:

I finally figured out what was wrong. There seems to be an enter image description here

enter image description here

This problem only seems to affect the docstring but doesn't affect autocomplete. Thanks to others who tried to help with this question and hope it helps those who might come across the same problem.

  • Related