Skip to content

Commit 27171fc

Browse files
committed
feat: add uv installation support for basedpyright
1 parent 15921c4 commit 27171fc

File tree

1 file changed

+32
-6
lines changed

1 file changed

+32
-6
lines changed

src/lsp_client/clients/basedpyright.py

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,17 +53,43 @@ async def ensure_basedpyright_installed() -> None:
5353
if shutil.which("basedpyright-langserver"):
5454
return
5555

56-
logger.warning(
57-
"basedpyright-langserver not found, attempting to install via npm..."
58-
)
56+
# Try uv tool install
57+
if shutil.which("uv"):
58+
logger.info("Attempting to install basedpyright via uv tool install...")
59+
try:
60+
await anyio.run_process(["uv", "tool", "install", "basedpyright"])
61+
logger.info("Successfully installed basedpyright via uv")
62+
return
63+
except CalledProcessError:
64+
logger.warning(
65+
"Failed to install basedpyright via uv, trying other methods..."
66+
)
5967

68+
# Try npm
69+
if shutil.which("npm"):
70+
logger.info("Attempting to install basedpyright via npm...")
71+
try:
72+
await anyio.run_process(["npm", "install", "-g", "basedpyright"])
73+
logger.info("Successfully installed basedpyright via npm")
74+
return
75+
except CalledProcessError:
76+
logger.warning(
77+
"Failed to install basedpyright via npm, trying other methods..."
78+
)
79+
80+
# Try pip
81+
import sys
82+
83+
logger.info("Attempting to install basedpyright via pip...")
6084
try:
61-
await anyio.run_process(["npm", "install", "-g", "basedpyright"])
62-
logger.info("Successfully installed basedpyright-langserver via npm")
85+
await anyio.run_process(
86+
[sys.executable, "-m", "pip", "install", "basedpyright"]
87+
)
88+
logger.info("Successfully installed basedpyright via pip")
6389
return
6490
except CalledProcessError as e:
6591
raise ServerInstallationError(
66-
"Could not install basedpyright-langserver. Please install it manually with 'npm install -g basedpyright' or 'pip install basedpyright'. "
92+
"Could not install basedpyright-langserver. Please install it manually with 'uv tool install basedpyright', 'npm install -g basedpyright' or 'pip install basedpyright'. "
6793
"See https://github.com/detachhead/basedpyright for more information."
6894
) from e
6995

0 commit comments

Comments
 (0)