Pylance is an IDE plugin for VSCode that provides python language autocomplete and static analysis by integrating with Python language servers such as pyright.

Configure Pyright

It is worth adding pyright configuration to your project’s pyproject.toml file

[tool.pyright]
include = [
    "packagename/",
]
pythonVersion = "3.9"
typeCheckingMode = "strict"

Full documentation for valid pyright settings can be found here

Autocomplete Suggestions Missing

By default Pylance will only index libraries to a depth of 1 submodule which is detrimental when working with complex libraries like django or scikit learn which can have 4 or 5 levels of submodules.

You can override this behaviour in your vscode settings (as documented here):

  "python.analysis.packageIndexDepths": [
    {
      "name": "django",
      "depth": 6,
      "includeAllSymbols": true
    },
  ],

Pylance has different levels of comprehensiveness (trade off against compute/memory requirements). The different levels (light, default, full) are detailed here.

In full mode, the tool will index all libraries to 4 layers deep.

includeAllSymbols simply tells pylance whether to honour the __all__ variable as per the documentation:

  • If includeAllSymbols is set to false, only symbols in each package’s __all__ are included. When it’s set to true, Pylance will index every module/top level symbol declarations in the file.