Modern Python Projects Transcripts
Chapter: Your code editor
Lecture: Pylance and a language server protocol

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Python extension, that we just installed came with a lot of features.
0:03 For example, auto completion jump to definition and more.
0:06 They all came from a tool called Python language server.
0:11 Python language server is part of the language server protocol.
0:15 This is a new thing that was created to stop duplicating work when people create plugins
0:20 for specific programming languages for different code Editors. without language server protocol,
0:26 When someone was creating a Python plugin for VSCode,
0:29 this plugin could only be used with VSCode.
0:32 You couldn't use it with Vim.
0:33 So, someone else had to create a plugin for Vim for Python and the same
0:37 for other code editors. So, each separate code editor needs to have a separate plugin
0:44 for each programming language. The language server protocol was created to separate programming languages
0:50 from code editors. So now we only need a python server plug in for Python
0:56 Ruby server plugin for Ruby and JavaScript server plugging for JavaScript,
1:00 and then for each code editor,
1:02 we need a plugin that will let you use language server protocol.
1:06 So instead of having a plugin per language and per editor.
1:09 We only need one plugin per language and one plugin per editor.
1:14 So if the VSCode client plugin,
1:15 we can use Python server plugin,
1:18 Ruby server plugin or JavaScript server plugin and the same of the Vim and Emacs
1:23 clients. Why am I telling you this?
1:26 Well, that's because there is a new Python language server plugin being developed for
1:31 VSCode. That's called Pylance.
1:34 If you're watching this video in the future,
1:35 It might replace the default Python language server that it's currently used with the python package
1:40 But for now, you can install it separately by searching for Pylance in the
1:44 extension marketplace. As you can see,
1:46 we would have to install it by clicking this button,
1:49 and when you install it, you can see that the list of features is pretty
1:53 impressive. For example, you have better Docstrings in the auto completion,
1:57 you get auto imports, that will automatically import modules as you use them in your code
2:02 You also have faster reporting of errors and so on...
2:05 If you want, you can check it out.
2:06 Just click this install button and you will get a popup that you need to
2:10 reload VSCode. So, let's go ahead.
2:14 Now you can see we have Pylance installed here and we can check if it's actually
2:18 being used by going to settings and searching for language server.
2:24 You can see here we have Python language server and, on this list, here we have
2:30 Pylance. If you want to go back to the default language server that comes with
2:34 the Python package, you can select Microsoft.
2:37 And if you don't like any of them,
2:38 you can also try the Jedi language server.
2:42 For the rest of this course.
2:43 I will stick with the standard Python language server,
2:45 so I will select Microsoft. But I definitely recommend that you check out Pylance when you have a chance.