Microsoft recently released a new VS Code extension called Pylance, an improved language server specifically for Python.

To install the Pylance extension, simply search for Pylance from the marketplace in VS Code.

enter image description here



Features

  • Docstrings
  • Signature help, with type information
  • Better parameter suggestions
  • Faster code completion
  • Auto-import/remove feature
  • Error checking
  • Code outline/navigation/lens
  • Type check
  • IntelliCode compatibility
  • Jupyter Notebook compatibility



Settings and Customization

Pylance offers few customizations in which you can modify the settings in the setting.json file.

python.analysis.typeCheckingMode

To specify the level of type checking analysis performed;

  • Default: off
  • Available values: off, basic, strict

python.analysis.diagnosticMode

To allow a user to specify what files they want the language server to analyze to get problems flagged in their code.

  • Default: openFileOnly
  • Available values: workspace, openFileOnly

python.analysis.stubPaths

To allow a user to specify a path to a directory that contains custom type stubs. Each package’s type stub file(s) are expected to be in its own subdirectory

Default value: ./typings

python.analysis.autoSearchPaths

To automatically add search paths based on some predefined names (like src).

  • Default value: true
  • Available values: true/false

python.analysis.diagnosticSeverityOverrides

To allow a user to override the severity levels for individual diagnostics should they desire.

  • Available values:
    • error (red squiggle)
    • warning (yellow squiggle)
    • information (blue squiggle)
    • none (disables the rule)

Rule can be found here

python.analysis.useLibraryCodeForTypes

To parse the source code for a package when a typestub is not found

  • Default values: true
  • Available values: true/false