Inconsistent type inference in LSP and CLI for external search paths
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 68/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Domain
- cli, developer-experience, devtools
Research direction
Reproduce the mismatch with the supplied project structure, pyproject.toml, test.py, and Zed settings.json, comparing pyrefly check with the LSP result. Start by tracing workspace configuration and external search-path handling in the LSP and CLI entry points. Done means both paths infer datetime for now().
Written by the indexing model from the issue text.
Description
Describe the Bug
I have a file system structure like this:
./
├── extproject/
│ └── src/
│ └── extpkg/
│ ├── __init__.py
│ └── date.py
└── project/
├── .zed/
│ └── settings.json
├── pyproject.toml
└── test.py
project is the project I'm working on with Zed, and extproject is a third-party project that my project depends on.
When running pyrefly as a language server in Zed, the return type of now() is inferred as "Unknown":
However, on the command line it is recognized correctly:
$ pyrefly check
INFO Checking project configured at `/home/jan/Downloads/pyrefly-test/project/pyproject.toml`
INFO revealed type: datetime [reveal-type]
--> test.py:5:12
|
5 | reveal_type(test)
| ------
INFO 0 errors
$ pyrefly --version
pyrefly 1.3.1
project/test.py:
from typing_extensions import reveal_type
from extpkg.date import now
test = now()
reveal_type(test)
project/pyproject.toml:
[tool.pyrefly]
search-path = ["../extproject/src"]
preset = "default"
projects/.zed/settings.json:
{
"languages": {
"Python": {
"language_servers": [
"pyrefly",
"!ruff",
"!ty",
"!basedpyright",
"!pyright",
"!pylsp",
"...",
],
},
},
}
exproject/src/extpkg/date.py:
from datetime import datetime
from zoneinfo import ZoneInfo
def now():
return datetime.now(ZoneInfo("UTC"))
I've also attached the files here.
pyrefly-test.zip
Sandbox Link
No response
(Only applicable for extension issues) IDE Information
Zed 1.20.2
Commit: 7c451e694f3c52ee0aeb01d7e28b5fa18cd0ad2f
Version: 1.20.2+stable.360.7c451e694f3c52ee0aeb01d7e28b5fa18cd0ad2f
Pyrefly extension version 0.0.1
LSP log
INFO Language server processed event `DidChangeConfiguration` in 0.00s (0.01s waiting)
INFO File /home/jan/Downloads/pyrefly-test/project/test.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:///home/jan/Downloads/pyrefly-test/project/test.py
INFO Validated open files and committed transaction.
INFO Language server processed event `DidOpenTextDocument` in 0.09s (0.01s waiting)
INFO Language server processed event `LspResponse` in 0.00s (0.09s waiting)
INFO Could not decode `LspConfig` from Null, skipping client configuration request: invalid type: null, expected struct LspConfig.
INFO Client configuration applied to workspace: Some(Url { scheme: "file", cannot_be_a_base: false, username: "", password: None, host: None, port: None, path: "/home/jan/Downloads/pyrefly-test/project", query: None, fragment: None })
INFO Could not decode `LspConfig` from Null, skipping client configuration request: invalid type: null, expected struct LspConfig.
INFO Client configuration applied to workspace: None
INFO Language server processed event `LspResponse` in 0.00s (0.09s waiting)
INFO Could not decode `LspConfig` from Null, skipping client configuration request: invalid type: null, expected struct LspConfig.
INFO Client configuration applied to workspace: Some(Url { scheme: "file", cannot_be_a_base: false, username: "", password: None, host: None, port: None, path: "/home/jan/Downloads/pyrefly-test/project", query: None, fragment: None })
INFO Could not decode `LspConfig` from Null, skipping client configuration request: invalid type: null, expected struct LspConfig.
INFO Client configuration applied to workspace: None
INFO Language server processed event `LspResponse` in 0.00s (0.09s waiting)
INFO Handling non-canceled request textDocument/inlayHint (2)
INFO Language server processed event `LspRequest(textDocument/inlayHint)` in 0.00s (0.05s waiting)
INFO Handling non-canceled request textDocument/semanticTokens/full (3)
INFO Language server processed event `LspRequest(textDocument/semanticTokens/full)` in 0.00s (0.01s waiting)
INFO Publishing workspace diagnostics for 1 non-open files.
INFO Ran task on recheck_queue heavy task queue. Queue time: 0.00, task time: 0.00
INFO Populating all files in the config (File("/home/jan/Downloads/pyrefly-test/project/pyproject.toml")).
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 Language server processed event `LspResponse` in 0.00s (0.00s waiting)
INFO Prepare to check 1 files.
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.00, task time: 0.00
INFO Populating up to 2000 files in the workspace ("/home/jan/Downloads/pyrefly-test/project").
INFO Published 1 diagnostics for file:///home/jan/Downloads/pyrefly-test/project/test.py
INFO Validated open files and committed transaction.
INFO Publishing workspace diagnostics for 1 non-open files.
INFO Language server processed event `RecheckFinished` in 0.00s (0.00s waiting)
INFO Prepare to check 1 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.00, task time: 0.00
INFO Publishing workspace diagnostics for 1 non-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:///home/jan/Downloads/pyrefly-test/project/test.py
INFO Validated open files and committed transaction.
INFO Publishing workspace diagnostics for 1 non-open files.
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 Language server processed event `LspResponse` 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/documentHighlight (4)
INFO Language server processed event `LspRequest(textDocument/documentHighlight)` in 0.00s (0.00s waiting)
INFO Handling non-canceled request textDocument/foldingRange (5)
INFO Language server processed event `LspRequest(textDocument/foldingRange)` in 0.00s (0.00s waiting)
INFO Handling non-canceled request textDocument/codeLens (6)
INFO Language server processed event `LspRequest(textDocument/codeLens)` in 0.00s (0.00s waiting)
INFO Handling non-canceled request textDocument/semanticTokens/full (7)
INFO Language server processed event `LspRequest(textDocument/semanticTokens/full)` in 0.00s (0.00s waiting)
INFO Handling non-canceled request textDocument/codeAction (8)
INFO Language server processed event `LspRequest(textDocument/codeAction)` in 0.00s (0.00s waiting)
- Dominant language
- Rust
- Stars
- 7k
- Forks
- 521
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from facebook/pyrefly
-
Difficulty 2/5 Half a day Newbie friendliness 68/100
-
typechecking
Difficulty 5/5 Over a week Newbie friendliness 35/100
-
False positive `unexpected-keyword` for inherited SQLAlchemy mapped columns in `Update.values()` Opensqlalchemy typechecking
Difficulty 3/5 1-2 days Newbie friendliness 72/100
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
All issues in facebook/pyrefly
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
kwakseongjae/auto-hwp#319 ·
-
area:cli bug filter-quality good first issue priority:medium
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
bevyengine/bevy#25861 ·
-
comp-datalake
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
ClickHouse/ClickHouse#121222 ·
-
enhancement remote
Difficulty 2/5 1-3 hours Newbie friendliness 68/100