Repository navigation
feat(check): PyrightFactsAdapter — pyright-langserver LSP hover oracle - #126
Merged
Merged
Conversation
ruff format under target-version py314 strips except-tuple parens into 'except A, B:', which is only valid on Python 3.14+ and breaks import on the 3.13 dev venv — pytest collection failed on tests/compat2. Restores the intended (OSError, ValueError) handler; no semantic change.
Contributor
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
Implements FactsProvider against a long-lived pyright-langserver
subprocess over stdio JSON-RPC: lazy spawn, hover + didOpen with
publishDiagnostics wait, per-(uri,line,char) cache, clean shutdown.
Hover plaintext is parsed back into the existing TypeFacts/CallableFacts
dataclasses; unexpected shapes degrade to 'no fact'.
- Binary resolution: PYRIGHT_LANGSERVER_BIN env (shlex) or constructor
command, default 'pyright-langserver --stdio'
- facts_provider('pyright') now dispatches to the adapter
- AnnAssign targets take the declared annotation type (hover reports
narrowed types); Call expressions record the callee's return type;
each @overload def name hover contributes an overload choice
- tests: hover-text parser units + skip-marked langserver smoke test
- self-census ballpark +139 fences for the stdio/threading plumbing
devin-ai-integration
Bot
force-pushed
the
work/pyright-facts-adapter
branch
from
October 18, 2026 19:56
1c39302 to
bf7634b
Compare
…adapter # Conflicts: # tests/test_census_self.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements
PyrightFactsAdapterinsrc/pyscriptc/typefacts.py— the secondFactsProvider, backed bypyright-langserverover stdio LSP rather than a new pyright CLI surface.facts_provider("pyright")now returns it (wired through the existing--checker pyrightconvention; default unchanged).initialize→didOpen(+publishDiagnosticswait) →textDocument/hoverper query, with a per-(uri, line, char)cache and cleanshutdown/exit. Binary resolution:PYRIGHT_LANGSERVER_BINenv (shlex) or constructorcommand, defaultpyright-langserver --stdio.(function) def f(a: int) -> str,(variable) x: list[int],(parameter) p: T,(method),class Box(),Name@Scopetypevars,Literal[...],(+N overloads)tails. Tolerant: unexpected shapes degrade to "no fact".MypyFactsAdapter's contract:AnnAssigntargets record the declared type (hover reports narrowed types),Callnodes record the callee's return type, each@overloaddef-name hover contributes an overload choice,__main__.-prefixed qualnames.PYRIGHT_LANGSERVER_BIN/pyright-langserveris available. No network.Preceding fix commit (drop-able):
fix(compat2)restores parens incache.py'sexcept (OSError, ValueError)— ruff format undertarget-version = "py314"had stripped them. The file is on CI's format--excludelist so both forms are legal, but only the parenthesized form parses on Python <3.14. Noteexamples/gates_probe.pyhas the same corruption but is NOT format-excluded — CI's py314ruff format --checkrequires the stripped form, so it stays; on <3.14 boxes it simply doesn't parse (an environment gap, not a code bug — CI/dev should run 3.14).Self-census ballpark bumped +139 fences for the new stdio/threading plumbing.
Known gaps
Callable[...]hover types can't express positional-only/keyword-only markers — those come fromdefsignatures only.UV_PYTHON=3.14, as CI sets) — under 3.13 the py314-normalizedexcept A, B:sources and PEP-649 forward-ref tests fail. Verified green on 3.14.8.Link to Devin session: https://app.devin.ai/sessions/7c91c4c693244acdb1bf765f5bc55deb
Open in Devin Desktop: https://app.devin.ai/desktop/session/7c91c4c693244acdb1bf765f5bc55deb?variant=devin
Requested by: @espetro