Search code examples
pythonpycharmpyright

Pyright Intellij plugin saves too quickly and causes refactoring


I'm using Intellij Ultimate as my IDE and the Ruff plugin to format my code on save.
Intellij's type checker is not very strict, and I want to integrate the Pyright type checker instead. I downloaded and installed the Pyright plugin for Intellij and Pycharm.

Now the problem is Pylint is constantly saving the file I'm working on, which triggers Ruff. This proves to be very annoying as I can't even import files: while I'm typing new imports, Pyright saves the file, making Ruff delete my unfinished import.

The following is noted in the Pyright plugin docs:

Warning: Depending on the running mode, it might save your files at very fast pace.

Does anyone know how to change the 'running mode' or have any solution for this?
The Pyright plugin has limited setting options and the autosave doesn't seem to be configurable.


Solution

  • (Disclaimer: I'm the maintainer of the plugin.)

    This is a frequently asked question. See the docs for more information on what they do and which one to choose.

    TLDR: Open your settings panel, then Tools | Pyright (Global):

    Click the "LSP4IJ" radio button, set your language server executable the same way you did for the default running mode (only that this one's name should be pyright-langserver), then save and return to your files.