Home > Back-end >  Python: Visual Studio Code not suggesting auto import
Python: Visual Studio Code not suggesting auto import

Time:07-08

So I have "python.analysis.indexing": true in settings.json.

Any clue why Session from sqlalchemy.orm (a package two-levels deep) is not in the suggestion list?

enter image description here

while, create_engine from sqlalchemy (top level package) is?

enter image description here

Only symbols from a first level of a package in 3rd party libraries seem to be appearing in the suggestion list

CodePudding user response:

Currently we only support first level symbols on auto import by default.

you need to use the hidden options to enable it if necessary.

In settings.json, put this for us to pick the symbols up for auto import:

 "python.analysis.packageIndexDepths":[["PySide6",2]],

what it basically means is ["package name", "max depth to search"]. "max depth" basically means how many dot you need to access the module you want.

For example, PySide6.QtWidgets this is 2 level deep.

Deeper you go, Pylance will take more time to scan python files.

You can also use [["",2]], it will change default depth.

  • Related