Basedpyright is a good open-source Python LSP server
If you write Python in Vim or Emacs, then to get type checking and tab completion you need a "language server" interacting via LSP protocol. There are good language servers for Go and Rust that come with the standard tooling, but I struggled to find a decent one for Python. That changed when I came across Basedpyright.
Basedpyright is a fork of Pyright. The original Pyright is maintained by Microsoft, and the problem with it is that not all features that the VSCode plugin (Pylance) supports end up in the open-source Pyright. For example:
- import suggestions
- inlay hints (super useful in practice)
- docstrings for certain builtins and modules
Basedpyright adds those features, and fixes certain arguably suboptimal decisions in the type checker (like handling of Any type, redefining inherited attributes, etc).
I've tried it on my own project, and on the surface it gave me decent type inference/checking. Not fully on par with pyre-check from Facebook, but close enough. On the other hand, as compared to pyre-check, this one has full set of functionality like code completion and import sorting.
If you want to try it, the installation is quite easy (unlike with Pyright):
pip install basedpyright
And then configure your editor.