Real Python Logo

Episode 28: Using Pylance to Write Better Python Inside of Visual Studio Code

The Real Python Podcast

Sep 25, 2020 50m

A big decision a developer has to make is what tool to use to write code? Would you like an editor that understands Python, and is there to help with suggestions, definitions, and analysis of your code? For many developers, its the free tool, Visual Studio Code. This week on the show, we have Savannah Ostrowski, program manager for the Python Language Server and Python in Visual Studio. We discuss Pylance, a new language server with fast, feature-rich language support for Python in VS Code.

Savannah explains what a language server is and the types of features it can provide. This includes type information, code completion, automatic-imports, dead code analysis, code navigation, and more. We also have a discussion about type checking in Python, which led to how Pylance leverages the static type checking tool Pyright, and what are type stubs (.pyi files).

Topics:

  • 00:00:00 – Introduction
  • 00:01:47 – Current Role at Microsoft
  • 00:03:01 – Background with Python
  • 00:04:21 – Origins of Pylance
  • 00:06:53 – What is a language server?
  • 00:09:56 – Diving deeper into the features individually
  • 00:14:42 – Code navigation and diagnostics
  • 00:15:43 – Methods of defining types and stub files
  • 00:17:28 – What are examples of stub files?
  • 00:21:16 – Comparing Pyright to Mypy
  • 00:23:56 – Video Course Spotlight
  • 00:25:02 – Auto-imports are a contentious feature
  • 00:28:36 – Code actions and dead code analysis
  • 00:31:46 – Pylance working with Jupyter notebooks in VSCode
  • 00:33:30 – Multiple workspaces
  • 00:36:16 – Why do you like to work on developer tools?
  • 00:39:35 – How does a tool like Pylance help a beginner?
  • 00:42:31 – What are you excited about in the world of Python?
  • 00:46:25 – What do you want to learn next?
  • 00:49:24 – Thanks and goodbyes

Show Links: