History

Add pyright workspace configuration (#14265)

Release Notes: - Added support for pyright workspace configuration, as described in https://microsoft.github.io/pyright/#/settings .

FilipeBisinella committed 2 years ago

Commit 21c5ce21 parent 3deb0002 files · +72 −3Browse files

Showing the changes to docs/src/languages/python.md (1 of 2 files). Show all

Unified · Split

docs/src/languages/python.md+45−0
@@ -11,6 +11,35 @@ The [pyright](https://github.com/microsoft/pyright) language server offers flexi · 10 unmodified lines
11 11
12For more information, see the Pyright [configuration documentation](https://microsoft.github.io/pyright/#/configuration).12For more information, see the Pyright [configuration documentation](https://microsoft.github.io/pyright/#/configuration).
13 13
14### Settings
15
16The [pyright](https://github.com/microsoft/pyright) language server also accepts specific LSP related settings, not necessarily connected to a project. These can be changed in the `lsp` section of your `settings.json`.
17
18For example, in order to:
19- use strict type-checking level
20- diagnose all files in the workspace instead of the only open files default
21- provide the path to a specific python interpreter
22
23```json
24{
25 "lsp": {
26 "pyright": {
27 "settings": {
28 "python.analysis": {
29 "diagnosticMode": "workspace",
30 "typeCheckingMode": "strict"
31 },
32 "python": {
33 "pythonPath": ".venv/bin/python"
34 }
35 }
36 }
37 }
38}
39```
40
41For more information, see the Pyright [settings documentation](https://microsoft.github.io/pyright/#/settings).
42
14### Virtual environments43### Virtual environments
15 44
16A python [virtual environment](https://docs.python.org/3/tutorial/venv.html) allows you to store all of a project's dependencies, including the Python interpreter and package manager, in a single directory that's isolated from any other Python projects on your computer.45A python [virtual environment](https://docs.python.org/3/tutorial/venv.html) allows you to store all of a project's dependencies, including the Python interpreter and package manager, in a single directory that's isolated from any other Python projects on your computer.
@@ -48,6 +77,22 @@ venvPath = "." · 31 unmodified lines
48venv = ".venv"77venv = ".venv"
49```78```
50 79
80You can also configure this option directly in your `settings.json` file ([pyrights settings](#settings)), as recommended in [Configuring Your Python Environment](https://microsoft.github.io/pyright/#/import-resolution?id=configuring-your-python-environment).
81
82```json
83{
84 "lsp": {
85 "pyright": {
86 "settings": {
87 "python": {
88 "pythonPath": ".venv/bin/python"
89 }
90 }
91 }
92 }
93}
94```
95
51### Code formatting96### Code formatting
52 97
53The Pyright language server does not provide code formatting. If you want to automatically reformat your Python code when saving, you'll need to specify an \_external_code formatter in your settings. See the [configuration](../configuring-zed.md) documentation for more information.98The Pyright language server does not provide code formatting. If you want to automatically reformat your Python code when saving, you'll need to specify an \_external_code formatter in your settings. See the [configuration](../configuring-zed.md) documentation for more information.