Skip to content

Commit f06ea93

Browse files
authored
Add basedpyright support (#1152)
* Add basedpyright support * Lint * Deduplicate yarn lock * Lower basedpyright priority to meet test assumptions
1 parent 2ffe367 commit f06ea93

File tree

10 files changed

+828
-273
lines changed

10 files changed

+828
-273
lines changed

atest/_fixtures/overrides.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
},
55
"@jupyter-lsp/jupyterlab-lsp:plugin": {
66
"language_servers": {
7+
"basedpyright": {
8+
"priority": 40
9+
},
710
"pylsp-with-override-json": {
811
"serverSettings": {
912
"pylsp.plugins.flake8.enabled": true,

atest/suites/01_Editor.robot

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,11 @@ Python (pyright)
7373
Editor Shows Features for Server pyright Python example.py Diagnostics=is not defined (Pyright)
7474
... Jump to Definition=${def}
7575

76+
Python (basedpyright)
77+
${def} = Set Variable lastToken:fib
78+
Editor Shows Features for Server basedpyright Python example.py Diagnostics=is not defined (basedpyright)
79+
... Jump to Definition=${def}
80+
7681
R
7782
${def} = Set Variable lastToken:fib
7883
Editor Shows Features for Language R example.R Diagnostics=Put spaces around all infix operators

python_packages/jupyter_lsp/jupyter_lsp/specs/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
# flake8: noqa: F401
55

6+
from .basedpyright import BasedPyrightLanguageServer
67
from .bash_language_server import BashLanguageServer
78
from .dockerfile_language_server_nodejs import DockerfileLanguageServerNodeJS
89
from .javascript_typescript_langserver import JavascriptTypescriptLanguageServer
@@ -22,6 +23,7 @@
2223
from .vscode_json_languageserver import VSCodeJSONLanguageServer
2324
from .yaml_language_server import YAMLLanguageServer
2425

26+
basedpyright = BasedPyrightLanguageServer()
2527
bash = BashLanguageServer()
2628
css = VSCodeCSSLanguageServer()
2729
dockerfile = DockerfileLanguageServerNodeJS()
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from .config import load_config_schema
2+
from .utils import ShellSpec
3+
4+
5+
class BasedPyrightLanguageServer(ShellSpec):
6+
key = "basedpyright"
7+
cmd = "basedpyright-langserver"
8+
args = ["--stdio"]
9+
languages = ["python"]
10+
spec = dict(
11+
display_name=key,
12+
mime_types=["text/python", "text/x-ipython"],
13+
urls=dict(
14+
home="https://github.com/DetachHead/basedpyright",
15+
issues="https://github.com/DetachHead/basedpyright/issues",
16+
),
17+
install=dict(
18+
pip="pip install basedpyright",
19+
conda="conda install -c conda-forge basedpyright",
20+
),
21+
config_schema=load_config_schema(key),
22+
requires_documents_on_disk=False,
23+
)

python_packages/jupyter_lsp/jupyter_lsp/specs/config/basedpyright.schema.json

Lines changed: 743 additions & 0 deletions
Large diffs are not rendered by default.

python_packages/jupyter_lsp/jupyter_lsp/specs/config/pyright.schema.json

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@
230230
},
231231
"reportOptionalOperand": {
232232
"type": "string",
233-
"description": "Diagnostics for an attempt to use an Optional type as an operand to a binary or unary operator (like '+', '==', 'or', 'not').",
233+
"description": "Diagnostics for an attempt to use an Optional type as an operand to a binary or unary operator (like '+', '<<', '~').",
234234
"default": "error",
235235
"enum": ["none", "information", "warning", "error"]
236236
},
@@ -474,6 +474,12 @@
474474
"default": "error",
475475
"enum": ["none", "information", "warning", "error"]
476476
},
477+
"reportUnhashable": {
478+
"type": "string",
479+
"description": "Diagnostics for the use of an unhashable object in a container that requires hashability.",
480+
"default": "error",
481+
"enum": ["none", "information", "warning", "error"]
482+
},
477483
"reportUnsupportedDunderAll": {
478484
"type": "string",
479485
"description": "Diagnostics for unsupported operations performed on __all__.",
@@ -516,6 +522,12 @@
516522
"default": "none",
517523
"enum": ["none", "information", "warning", "error"]
518524
},
525+
"reportUnreachable": {
526+
"type": "string",
527+
"description": "Diagnostics for code that is determined by type analysis to be unreachable.",
528+
"default": "none",
529+
"enum": ["none", "information", "warning", "error"]
530+
},
519531
"reportShadowedImports": {
520532
"type": "string",
521533
"description": "Diagnostics for files that are overriding a module in the stdlib.",
@@ -538,8 +550,8 @@
538550
},
539551
"python.analysis.typeCheckingMode": {
540552
"type": "string",
541-
"default": "basic",
542-
"enum": ["off", "basic", "strict"],
553+
"default": "standard",
554+
"enum": ["off", "basic", "standard", "strict"],
543555
"description": "Defines the default rule set for type checking.",
544556
"scope": "resource"
545557
},
@@ -576,6 +588,12 @@
576588
"description": "Disables the “Organize Imports” command.",
577589
"scope": "resource"
578590
},
591+
"pyright.disablePullDiagnostics": {
592+
"type": "boolean",
593+
"default": false,
594+
"description": "Disables the use of pull diagnostics.",
595+
"scope": "machine"
596+
},
579597
"python.pythonPath": {
580598
"type": "string",
581599
"default": "python",

python_packages/jupyter_lsp/setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ etc/jupyter/jupyter_server_config.d = jupyter_lsp/etc/jupyter-lsp-jupyter-server
3737

3838
[options.entry_points]
3939
jupyter_lsp_spec_v1 =
40+
basedpyright = jupyter_lsp.specs:basedpyright
4041
bash-language-server = jupyter_lsp.specs:bash
4142
dockerfile-language-server-nodejs = jupyter_lsp.specs:dockerfile
4243
javascript-typescript-langserver = jupyter_lsp.specs:ts_old

requirements/dev.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
-r ./utest.txt
33
-r ./atest.txt
44
packaging
5-
pyls-black
6-
pyls-isort
7-
pyls-mypy
5+
python-lsp-server
6+
python-lsp-black
7+
pylsp-mypy
88
ruamel.yaml

requirements/github-actions.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ dependencies:
1313
- nodejs {nodejs}
1414
# for python language server (and development)
1515
- python-lsp-server >=1.7.4
16+
- basedpyright
1617
- flake8
1718
- autopep8
1819
- pyflakes

0 commit comments

Comments
 (0)