facebook / facebook/pyrefly

LSP doesn't work in VSCode

Open
#3,077 6 comments 0 reactions 0 assignees View on GitHub
language-server question stale
Dominant language
Rust
Stars
7k
Forks
516
PR merge metrics
No merged PRs in 30d

Description

### Describe the Bug

The Pyrefly VSCode extension simply does not work at all on my system (MacOS 26.4).

For example, consider this code:

```python
import numpy as np
import numpy.typing as npt
import scipy as sp
from numpy.typing import ArrayLike

def my_special_fun(x: ArrayLike) -> np.ndarray:
x = np.atleast_1d(x)
x += 5
q = sp.stats.quantile(x, p=[0.25, 0.5, 0.75])
return x, q
```

Checking this with pyrefly, I get the expected type error in the CLI:

```bash
$ pyrefly check python/test_typing.py
ERROR Returned type `tuple[ndarray, ndarray[tuple[Any, ...], dtype[float64]]]` is not assignable to declared return type `ndarray` [bad-return]
--> python/test_typing.py:11:12
|
7 | def my_special_fun(x: ArrayLike) -> np.ndarray:
| ---------- declared return type
8 | x = np.atleast_1d(x)
9 | x += 5
10 | q = sp.stats.quantile(x, p=[0.25, 0.5, 0.75])
11 | return x, q
| ^^^^
|
INFO 1 error
```

However, nothing show up in VSCode:

Image

Relevent portions of the VSCode settings.json:

```json
"python.pyrefly.displayTypeErrors": "force-on",
"python.pyrefly.disableLanguageServices": false,
"pyrefly.trace.server": "verbose",
"python.languageServer": "None",
```

And my relevant `pyproject.toml` configuration:

```toml
[tool.pyrefly]
project-includes = ["python/*.py"]
project-excludes = ["**/*venv/**", "**/__pycache__", "**/.[!/.]*/**"]
use-ignore-files = true
min-severity = "error"
```

I'm using Pyrefly v0.60.0.

### Sandbox Link

_No response_

### (Only applicable for extension issues) IDE Information

If I clear the pyrefly language server log and save the above file (no edits), I get the following:

language server log: file save

```
INFO Language server processed event `DidSaveTextDocument` in 0.00s (0.00s waiting)
INFO Invalidated state, prepare to recheck open files.
INFO Ran task on recheck_queue heavy task queue. Queue time: 0.00, task time: 0.00
INFO Published 1 diagnostics for file:///workspace/python/test_typing.py
INFO Validated open files and committed transaction.
INFO Language server processed event `RecheckFinished` in 0.00s (0.00s waiting)
INFO Language server processed event `LspResponse` in 0.00s (0.00s waiting)
INFO Handling non-canceled request textDocument/semanticTokens/full (141)
INFO Language server processed event `LspRequest(textDocument/semanticTokens/full)` in 0.00s (0.00s waiting)
INFO [Pyrefly] DidChangeWatchedFiles: 2 file(s) changed (0 created, 2 modified, 0 removed, 0 unknown)
INFO Language server processed event `DidChangeWatchedFiles` in 0.00s (0.00s waiting)
INFO Invalidated state, prepare to recheck open files.
INFO Ran task on recheck_queue heavy task queue. Queue time: 0.00, task time: 0.00
INFO Published 1 diagnostics for file:///workspace/python/test_typing.py
INFO Validated open files and committed transaction.
INFO Language server processed event `RecheckFinished` in 0.00s (0.00s waiting)
INFO Language server processed event `LspResponse` in 0.00s (0.00s waiting)
INFO Handling non-canceled request textDocument/semanticTokens/full (142)
INFO Language server processed event `LspRequest(textDocument/semanticTokens/full)` in 0.00s (0.00s waiting)
```

If I use the command palette to restart the pyrefly client, it does appear to restart normally (assuming `Server process exited with code 0.` is normal after executing `pyrefly: Restart Pyrefly Client`):

language server log: restart

```
INFO waiting for connection to close
starting generic LSP server
INFO Reading messages
WARN PYTHONPATH environment variable is set to `:/workspace/python`. Checks in other environments may not include these paths.
shutting down server
[Error - 3:32:05 PM] Server process exited with code 0.
INFO File /workspace/python/test_typing.py opened, prepare to validate open files.
INFO Ran task on sourcedb_queue heavy task queue. Queue time: 0.00, task time: 0.00
INFO Published 1 diagnostics for file:///workspace/python/test_typing.py
INFO Validated open files and committed transaction.
INFO Language server processed event `DidOpenTextDocument` in 0.45s (0.00s waiting)
INFO Language server processed event `LspResponse` in 0.00s (0.45s waiting)
WARN PYTHONPATH environment variable is set to `:/workspace/python`. Checks in other environments may not include these paths.
INFO Client configuration applied to workspace: Some(Url { scheme: "file", cannot_be_a_base: false, username: "", password: None, host: None, port: None, path: "/workspace", query: None, fragment: None })
INFO Client configuration applied to workspace: None
INFO Language server processed event `LspResponse` in 0.05s (0.45s waiting)
INFO Request textDocument/documentSymbol (1) is canceled due to subsequent mutation
INFO Language server processed event `LspRequest(textDocument/documentSymbol)` in 0.00s (0.50s waiting)
INFO Request textDocument/inlayHint (2) is canceled due to subsequent mutation
INFO Language server processed event `LspRequest(textDocument/inlayHint)` in 0.00s (0.49s waiting)
INFO Request textDocument/foldingRange (3) is canceled due to subsequent mutation
INFO Language server processed event `LspRequest(textDocument/foldingRange)` in 0.00s (0.30s waiting)
INFO Request textDocument/codeLens (4) is canceled due to subsequent mutation
INFO Language server processed event `LspRequest(textDocument/codeLens)` in 0.00s (0.25s waiting)
INFO Request textDocument/documentSymbol (5) is canceled due to subsequent mutation
INFO Language server processed event `LspRequest(textDocument/documentSymbol)` in 0.00s (0.20s waiting)
INFO Language server processed event `LspResponse` in 0.00s (0.05s waiting)
INFO Language server processed event `LspResponse` in 0.00s (0.05s waiting)
INFO Handling non-canceled request textDocument/semanticTokens/full (6)
INFO Language server processed event `LspRequest(textDocument/semanticTokens/full)` in 0.00s (0.04s waiting)
INFO Handling non-canceled request textDocument/foldingRange (7)
INFO Language server processed event `LspRequest(textDocument/foldingRange)` in 0.00s (0.00s waiting)
INFO Invalidated config, prepare to recheck open files.
INFO Ran task on recheck_queue heavy task queue. Queue time: 0.00, task time: 0.44
INFO Ran task on recheck_queue heavy task queue. Queue time: 0.44, task time: 0.00
INFO Populating all files in the config (File("/workspace/pyproject.toml")).
INFO Prepare to check 0 files.
INFO Published 1 diagnostics for file:///workspace/python/test_typing.py
INFO Validated open files and committed transaction.
INFO Language server processed event `RecheckFinished` in 0.01s (0.00s waiting)
INFO Populated all files in the project path, prepare to recheck open files.
INFO Ran task on recheck_queue heavy task queue. Queue time: 0.44, task time: 0.01
INFO Populating up to 2000 files in the workspace ("/workspace").
INFO Published 1 diagnostics for file:///workspace/python/test_typing.py
INFO Validated open files and committed transaction.
INFO Language server processed event `RecheckFinished` in 0.00s (0.00s waiting)
INFO Language server processed event `LspResponse` in 0.00s (0.00s waiting)
INFO Language server processed event `LspResponse` in 0.00s (0.00s waiting)
INFO Handling non-canceled request textDocument/semanticTokens/full (8)
INFO Language server processed event `LspRequest(textDocument/semanticTokens/full)` in 0.00s (0.00s waiting)
INFO Handling non-canceled request textDocument/semanticTokens/full (9)
INFO Language server processed event `LspRequest(textDocument/semanticTokens/full)` in 0.00s (0.00s waiting)
INFO Prepare to check 0 files.
INFO Populated all files in the workspace, prepare to recheck open files.
INFO Ran task on recheck_queue heavy task queue. Queue time: 0.45, task time: 2.05
INFO Published 1 diagnostics for file:///workspace/python/test_typing.py
INFO Validated open files and committed transaction.
INFO Language server processed event `RecheckFinished` in 0.00s (0.00s waiting)
INFO Language server processed event `LspResponse` in 0.00s (0.00s waiting)
INFO Handling non-canceled request textDocument/semanticTokens/full (10)
INFO Language server processed event `LspRequest(textDocument/semanticTokens/full)` in 0.00s (0.00s waiting)
```

This is happening in a _devcontainer_ running Ubuntu 24.04.3 LTS, though I've also checked nothing is highlighted on the host either.

I'm running VSCode Version: 1.114.0 (Universal).

I actually don't know how to proceed debugging this; is there any advice? Or just wait for the VSCode extension to mature?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.