Running modes
Each distribution of Pyright comes with two executables:
pyright
(also referred to as "executable") and
pyright-langserver
("language server executable").
Aside from the main functionality discussed here, the first also provides a few more features and options, some of which are supported or used by this plugin.
Different running modes use different executables.
Comparison tables#
pyright |
pyright-langserver |
|
---|---|---|
Process type | Stops when finishes checking the file(s) | Long-running process |
Result | Only type checking diagnostics | Diagnostics and other LSP features |
Performance | Good | Better in many cases |
File reading method | From disk | File contents are sent via stdio |
Command line mode | LSP modes | |
---|---|---|
Executable used | pyright |
pyright-langserver |
Executable invoked | After each change | On project/supported file open |
Side effect | Will save all files to ensure synchronization | No side effects |
Error reporting | Notifications and IDE log | LSP4IJ console, notifications and IDE log |
Command line mode#
If this mode is selected, everytime a Python file is edited, this plugin will save it along with other (unsaved) files, then invoke the executable in a subprocess. The result of this process is rerouted back to the IDE in the form of visual annotations.
This mode requires two things to work correctly:
- That the executable you provide accepts said arguments, and
- that it outputs diagnostics in the formats defined here.
If any of these requirements are not met, a notification will be displayed.
Due to backward compatibility, this is the default mode. However, for better performance, LSP4IJ mode is recommended.
LSP4IJ and Native LSP client modes#
If either of these mode is selected, the language server will be invoked on file open. All LSP messages are then handled by the clients: either the LSP4IJ plugin, or the native client built into the IDE.
It is possible to use Pyright with LSP4IJ directly, but doing so is not recommended.
The differences between them are that of the client libraries. To use the native client, you must be using a paid IDE. On the other hand, LSP4IJ can be installed on any IDE.
Mode | Native LSP client | LSP4IJ |
---|---|---|
Client | Built-in | LSP4IJ (third-party) |
Can be used on | Paid IDEs | All IDEs |
Supported features* | Few | Much wider range |
UI integrations | Better | Good |
API stability | Unstable | Unstable |
Warning
On a (paid) IDE with both clients available, a LinkageError
will be thrown if Native LSP client is selected.
This is a known limitation.