python: Support nested analysis settings for Pyright and basedpyright (#62673)
# Objective Closes #62624 Recently, Pyright and BasedPyright changed how they retrieve analysis settings through `workspace/configuration` in microsoft/pyright#11480 and DetachHead/basedpyright#1847, respectively. Older versions requested the dotted `python.analysis` and `basedpyright.analysis` sections directly. Recent versions instead request the parent `python` or `basedpyright` section and read its nested `analysis` object. Because Zed stores many existing configurations under the dotted top-level keys, those settings are not included in its responses to the new parent-section requests and are therefore silently ignored. Zed's documentation and many users' settings still use configurations like this: https://github.com/zed-industries/zed/blob/4155155572601034cec5e5cfa9805bf88957553c/docs/src/languages/python.md?plain=1#L131-L148 all the configrations in `basedpyright.analysis` won't work now. ## Solution To maintain compatibility with both old and new servers, we need to support both configuration formats. This PR introduces `normalize_pyright_analysis_configuration`, which copies the analysis settings into both the dotted and nested formats. This ensures that the settings are available regardless of which format the language server requests. The documentation, however, has been updated to use the nested structure. ## Testing New unit tests have been added, and the changes have also been built and tested locally. ## Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [x] The content adheres to Zed's UI standards ([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) and [icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md) guidelines) - [x] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable --- Release Notes: - Fixed some Pyright and BasedPyright settings not being applied properly.
This commit is contained in:
1 parent
d5da3168c0
commit
45997391ba
2 files changed
+241
-120
No files matched your search
@@ -135,10 +135,12 @@ You can use the following configuration:
|
||||
"lsp": {
|
||||
"basedpyright": {
|
||||
"settings": {
|
||||
"basedpyright.analysis": {
|
||||
"diagnosticMode": "workspace",
|
||||
"inlayHints": {
|
||||
"callArgumentNames": false
|
||||
"basedpyright": {
|
||||
"analysis": {
|
||||
"diagnosticMode": "workspace",
|
||||
"inlayHints": {
|
||||
"callArgumentNames": false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -147,6 +149,8 @@ You can use the following configuration:
|
||||
}
|
||||
```
|
||||
|
||||
For compatibility with older configurations, Zed also accepts `basedpyright.analysis` as a top-level key within `settings`.
|
||||
|
||||
##### Configuration files
|
||||
|
||||
basedpyright reads project-specific configuration from the `pyrightconfig.json` configuration file and from the `[tool.basedpyright]` and `[tool.pyright]` sections of `pyproject.toml` manifests. `pyrightconfig.json` overrides `pyproject.toml` if configuration is present in both places.
|
||||
|
||||
Reference in new issue
Block a user