-
Notifications
You must be signed in to change notification settings - Fork 768
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pyright behavior changes after adding even an empty pyrightconfig.json #6446
Comments
Thanks for the issue. Settings for pylance and pyright are really confusing. Defaults for pylance are described here: https://github.com/microsoft/pylance-release?tab=readme-ov-file#settings-and-customization You're correct, specifying an empty pyrightconfig.json actually sets a number of settings to their default for a pyrightconfig.json. Those are described here: The reason why an empty pyrightconfig.json overrides everything is described here: If you want to duplicate the defaults for pylance in your pyrightconfig.json, you'd have something like so: {
"typeCheckingMode": "off",
"reportShadowedImports": "warning",
} While also leaving your settings.json blank. The pyrightconfig.json only overrides pyright settable settings in the settings.json so most of the defaults would still apply. I think we need to have a better explanation for all of this somewhere. |
ya, we should write that |
(just wanted to note that this was also discussed in #6373) Since this behavior seems to be confusing lots of people, it would be great to consider reverting the behavior rather than just relying on documentation of this footgun. |
Strong 👍 to making the behavior more predictable and consistent with the way that configuration files usually work. I wasted nearly an hour tracking down what was happening because it is so unexpected and because it is embedded in VS code (introducing some uncertainty in where the problem lies). My use case is that I want to exclude certain files from Pylance analysis on a per-project basis. That seems like very common thing to do, using something like:
It is COMPLETELY UNEXPECTED that this innocuous configuration would override any unrelated |
Thanks for all the valuable discussion. Especially the default values pylance uses: which solves my immediate problem by adding them to my I don't mind But some options around it, and even better, providing a way to merge the two at option-level (instead of overwriting entirely) would be great. |
I do mind. In monorepo environments we prefer having project-level overrides of global defaults. Having |
The fundamental problem for me is that the overrides are not explicit and do not behave like typical configuration precedence. Think about
The problem is that for the case where
This change in the precedence is what is confusing to users. Documentation is not really the answer. For my own work, I have been forced to stop using |
One remark is that we often use For me this is preferable to the current situation where |
Defaults for pyrightconfig.json are documented here: https://microsoft.github.io/pyright/#/configuration?id=environment-options, although the default are not very clearly stated. |
Apologies for the imprecise wording, I've updated the both comments with |
Environment data
Repro Steps
temp.py
file withpyright
.{}
.temp.py
again.Expected behavior
The pyright checker behavior should not change (i.e. no warning).
Actual behavior
pyright now shows an
error
level warning ofreportOptionalSubscript
.Logs
log.log
Above is just an example; when local
pyrightconfig.json
is enabled, it reports a lot more errors than default Pylance would (I tested with VS Code Insider with empty user settings.json).My gut feeling is this issue is caused by that Pylance by default uses some non-standard settings which got entirely overwritten by the local
pyrightconfig.json
even if it's empty (instead of merging the two).The problem is I cannot find where these settings are located.
The only thing I found is
C:\Users\ikena\.vscode-insiders\extensions\ms-python.vscode-pylance-2024.9.2\dist\schemas\pyrightconfig.schema.json
but it does not have anything different frompyright
default (e.g. it saysreportOptionalSubscript
is default toerror
:).
This makes reduplicating Pylance's default behavior (which I WANT) in a workspace where a
pyrightconfig.json
was introduced for other reasons (like addingexclude
) very difficult.Thanks.
The text was updated successfully, but these errors were encountered: