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. For example, auto completion jump to definition and more.
0:07 They all came from a tool called Python language server. Python language server is part of the language server protocol.
0:16 This is a new thing that was created to stop duplicating work when people create plugins
0:21 for specific programming languages for different code Editors. without language server protocol, When someone was creating a Python plugin for VSCode,
0:30 this plugin could only be used with VSCode. You couldn't use it with Vim. So, someone else had to create a plugin for Vim for Python and the same
0:38 for other code editors. So, each separate code editor needs to have a separate plugin
0:45 for each programming language. The language server protocol was created to separate programming languages
0:51 from code editors. So now we only need a Python server plug in for Python Ruby server plugin for Ruby and JavaScript server plugging for JavaScript,
1:01 and then for each code editor, we need a plugin that will let you use language server protocol.
1:07 So instead of having a plugin per language and per editor. We only need one plugin per language and one plugin per editor.
1:15 So if the VSCode client plugin, we can use Python server plugin, Ruby server plugin or JavaScript server plugin and the same of the Vim and Emacs
1:24 clients. Why am I telling you this? Well, that's because there is a new Python language server plugin being developed for
1:32 VSCode. That's called Pylance. If you're watching this video in the future,
1:36 It might replace the default Python language server that it's currently used with the Python package
1:41 But for now, you can install it separately by searching for Pylance in the extension marketplace. As you can see,
1:47 we would have to install it by clicking this button, and when you install it, you can see that the list of features is pretty
1:54 impressive. For example, you have better Docstrings in the auto completion,
1:58 you get auto imports, that will automatically import modules as you use them in your code You also have faster reporting of errors and so on...
2:06 If you want, you can check it out. Just click this install button and you will get a popup that you need to reload VSCode. So, let's go ahead.
2:15 Now you can see we have Pylance installed here and we can check if it's actually being used by going to settings and searching for language server.
2:25 You can see here we have Python language server and, on this list, here we have
2:31 Pylance. If you want to go back to the default language server that comes with the Python package, you can select Microsoft.
2:38 And if you don't like any of them, you can also try the Jedi language server. For the rest of this course.
2:44 I will stick with the standard Python language server,
2:46 so I will select Microsoft. But I definitely recommend that you check out Pylance when you have a chance.


Talk Python's Mastodon Michael Kennedy's Mastodon