How to use pyright version from the environment not the bundled pylance version #4375
Replies: 2 comments 8 replies
-
|
I think the easiest solution would be to lock the pyright version to whatever the latest Pylance is using. You can write a script to pull down the changelog and parse it to find the pyright version in use. You may also be just hitting differences in the CLI of pyright versus pylance, which is explained here: |
Beta Was this translation helpful? Give feedback.
-
|
We endeavor to minimize the differences between pyright and pylance. During most weeks, I release a single update to pyright on Tuesday evening, and the pylance team releases an update on Wed. The insiders build of Pylance uses the latest pyright build, so it's normally in sync with the latest release of pyright (except for the ~18-hour window between Tuesday evening and Wed afternoon). This past week was unusual in that I published two versions of pyright (1.1.308 and 1.1.309) due to an unusually large number of fixes and feature enhancements. Your experience with 1.1.308 is therefore likely to be an anomaly. If you experience a similar situation in the future, it would be helpful for us to learn about the details. You mentioned that you need to be on 1.1.308 for your code base. Am I correct in assuming that you recently started to use pyright and that some of the issues you encountered were recently reported and fixed in 1.1.308? Barring any regressions, this should be less of an issue now that your code base type checks with pyright. In addition to the suggestion from @rchiodo about pinning the version of pyright, another option is to have your team run the pyright VS Code extension rather than pylance. You'd forego the more advanced language server features provided by pylance in this case, so that's likely not a very appealing option, but I figured I'd throw it out there. As for your suggestion for allowing pylance to use an arbitrary version of pyright, that would require pylance to be built in a very different manner than it is currently, so it would be a heavy lift. It would also require that we maintain a formalized and stable interface contract between pylance and pyright code, and that would restrict our ability to refactor and modify internal code at will (which we do frequently today). That's something that neither myself (the main pyright maintainer) nor the pylance team would find very appealing. So I don't think that's a viable option. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
I work in a large codebase with many engineers and we are exploring standardising our workflow with VSCode and Pylance. Along with this we wish to use pyright for our CI checks.
Unfortunately, we are having trouble configuring the developer environment and the CI environment as pylance uses a bundled version of pyright. This causes us to have the following 2 issues:
VSCode will automatically update the extension which can cause new typing issues to surface for code unrelated to a developers work. We can advise our team to lock to a particular version of pylance but this causes difficulties due to having to broadcast when to upgrade. This causes additional friction when we wish to upgrade pyright and we need to determine which pylance to install, etc
For our current code, we need to be on the latest version of pyright (1.1.308) to address certain typing issues but the current release version of pylance (v2023.5.20) bundles pyright 1.1.306 and the current pre-release (v2023.5.21) bundles pyright 1.1.307. We are in a chicken-and-egg situation where either our CLI fails or our development environment displays errors.
I am wondering if there is a way to configure pylance to use the version of pyright that is accessible from the environment? This would mitigate the above issues for us.
Beta Was this translation helpful? Give feedback.
All reactions