Skip to content

Support basedpyright #1088

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

Open
krassowski opened this issue Jun 3, 2024 · 5 comments
Open

Support basedpyright #1088

krassowski opened this issue Jun 3, 2024 · 5 comments

Comments

@krassowski
Copy link
Member

basedpyright looks promising as an LSP server for Python https://github.com/DetachHead/basedpyright

@DetachHead
Copy link

fyi basedpyright now supports jupyter notebooks using the new notebook functionality introduced in LSP 3.17 so i think #1013 will address this

@krassowski
Copy link
Member Author

Thanks for chiming in! This extension works without the notebook format from LSP 3.17, and since pyright just works so should basedpyright :)

This issue is more to track adding a "spec" this is detecting if basedpyright is installed and listing its settings so that frontend can display them, as the LSP spec AFAIK still does not have a way to specify settings format. Something similar to:

class PyrightLanguageServer(NodeModuleSpec):
node_module = key = "pyright"
script = ["langserver.index.js"]
args = ["--stdio"]
languages = ["python"]
spec = dict(
display_name=key,
mime_types=["text/python", "text/x-ipython"],
urls=dict(
home="https://github.com/microsoft/pyright",
issues="https://github.com/microsoft/pyright/issues",
),
install=dict(
npm="npm install --save-dev {}".format(key),
yarn="yarn add --dev {}".format(key),
jlpm="jlpm add --dev {}".format(key),
),
config_schema=load_config_schema(key),
requires_documents_on_disk=False,
)

and:

{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Pyright Language Server Configuration",
"description": "Pyright Configuration Schema. Distributed under MIT License, Copyright (c) Microsoft Corporation.",
"allowComments": true,
"allowTrailingCommas": true,
"type": "object",
"properties": {
"python.analysis.autoImportCompletions": {
"type": "boolean",
"default": true,
"description": "Offer auto-import completions.",
"scope": "resource"
},
"python.analysis.autoSearchPaths": {
"type": "boolean",

@firai
Copy link

firai commented Mar 23, 2025

Thanks for the replying on Discord and here @DetachHead!

Regarding adding the spec to this extension with the current mechanism then, the command for talking to the language server seems to be basedpyright-langserver. There seems to be a schema in the basedpyright repo at https://github.com/DetachHead/basedpyright/blob/main/packages/vscode-pyright/schemas/pyrightconfig.schema.json? There's also a difference from pyright in that basedpyright can be installed via pip, rather than having to install via npm/yarn/jlpm.

@krassowski
Copy link
Member Author

There's also a difference from pyright in that basedpyright can be installed via pip, rather than having to install via npm/yarn/jlpm.

Oh right, I forgot about it. So it would resemble more:

class PythonLSPServer(PythonModuleSpec):
python_module = key = "pylsp"
languages = ["python"]
spec = dict(
display_name="python-lsp-server (pylsp)",
mime_types=["text/python", "text/x-ipython"],
urls=dict(
home="https://github.com/python-lsp/python-lsp-server",
issues="https://github.com/python-lsp/python-lsp-server/issues",
),
install=dict(
pip="pip install 'python-lsp-server[all]'",
conda="conda install -c conda-forge python-lsp-server",
),

unless we should search for both types of installations? Documentation recommends the pypi installation route, but I presume using an already installed node is also supported?

@firai
Copy link

firai commented Mar 23, 2025

Not sure if searching for both types is worth the complication, even if it's possible. I would think that most people will install via pip, which is recommended in the basedpyright docs, or via the conda family of tools (assuming that the conda-forge package installs the Python package rather than just the npm package).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants