Repository navigation
fix(completion): fall back to interpreter completion when jedi static analysis raises - #10100
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
All contributors have signed the CLA ✍️ ✅ |
There was a problem hiding this comment.
Pull request overview
Fixes marimo’s Python attribute completion so that when Jedi static analysis raises (e.g., known polars.concat(...) generic inference crash), completion gracefully falls back to interpreter-based completion instead of returning no suggestions. This also removes an unnecessary duplicate script.complete() call to avoid running potentially slow/crashy Jedi analysis twice per request.
Changes:
- Catch exceptions from the Jedi
Scriptcompletion path and treat them as “no static completions,” triggering interpreter fallback. - Eliminate a redundant second
script.complete()invocation in_get_completions(). - Add unit/regression tests, including an optional polars-based repro test (skipped if polars isn’t installed).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
marimo/_runtime/complete.py |
Adds exception-safe fallback from static Jedi completion to interpreter completion; removes redundant completion call. |
tests/_runtime/test_complete.py |
Adds tests verifying fallback on static-analysis exceptions and a polars concat regression test (skip-if-missing dependency). |
Light2Dark
left a comment
There was a problem hiding this comment.
looks good, just doing a pass to reduce comments.
|
Would you also mind signing the CLA @David-Wu1119 ? |
… analysis raises jedi's static analysis can raise while inferring some code — e.g. resolving the generic return type of polars' `concat` crashes with AttributeError (jedi#1990). `_get_completions()` only fell back to interpreter-based completion when the static path returned no completions, not when it raised, so a jedi crash silently killed attribute completion for the affected variable. Treat a static-analysis crash like "no static completions" so the interpreter fallback runs. Also removes a redundant second `script.complete()` call that ran the static analysis twice. Closes marimo-team#10055 Co-Authored-By: Claude Fable 5 <[email protected]>
0feeed2 to
b79b42a
Compare
|
recheck |
|
I have read the CLA Document and I hereby sign the CLA |
Co-authored-by: Shahmir Varqha <[email protected]>
|
Signed — thanks for the review! The CLA check is green now. |
|
🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.23.14-dev53 |
… analysis raises (marimo-team#10100) ## 📝 Summary Closes marimo-team#10055 jedi's static analysis can raise while inferring some code — e.g. resolving the generic return type of `polars.concat(...)` crashes with `AttributeError: 'TreeInstance' object has no attribute 'with_generics'` (upstream [jedi#1990](davidhalter/jedi#1990)). Because `_get_completions()` only fell back to interpreter-based completion when the static path returned *no* completions — not when it *raised* — a jedi crash silently killed attribute completion for the affected variable, even though the interpreter fallback would have completed it fine from the runtime globals. This implements the fix approach @manzt suggested on the issue: treat a static-analysis crash like "no static completions", so the interpreter fallback still gets a chance to run. The crash is logged at DEBUG (matching the existing logging in `complete()`). While restructuring, this also removes a redundant second `script.complete()` call in `_get_completions()` — `_get_completions_with_script()` already runs the completion, so the previous code ran jedi's (potentially slow or crashing) analysis twice per request. **Before:** with `df_x = pl.concat([df_a, df_b])` in a cell, typing `df_x.wi` produces no completion popup at all (silently, with nothing above DEBUG in the logs). **After:** `df_x.wi` completes (`with_columns`, `with_row_index`, ...) via the interpreter fallback. Tests: a unit test that simulates the static path raising (verifying the fallback runs), and a polars regression test with the exact repro from the issue (skipped when polars isn't installed). ## 📋 Pre-Review Checklist - [x] For large changes, or changes that affect the public API: this change was discussed or approved through an issue, on [Discord](https://marimo.io/discord?ref=pr), or the community [discussions](https://github.com/marimo-team/marimo/discussions) — approach suggested by @manzt in marimo-team#10055 (comment). - [x] Any AI generated code has been reviewed line-by-line by the human PR author, who stands by it. - [ ] Video or media evidence is provided for any visual changes (optional). <!-- not a visual change --> ## ✅ Merge Checklist - [x] I have read the [contributor guidelines](https://github.com/marimo-team/marimo/blob/main/CONTRIBUTING.md). - [x] Documentation has been updated where applicable, including docstrings for API changes. <!-- no public API change --> - [x] Tests have been added for the changes made. --------- Co-authored-by: Claude Fable 5 <[email protected]> Co-authored-by: Myles Scolnick <[email protected]> Co-authored-by: Shahmir Varqha <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
📝 Summary
Closes #10055
jedi's static analysis can raise while inferring some code — e.g. resolving the generic return type of
polars.concat(...)crashes withAttributeError: 'TreeInstance' object has no attribute 'with_generics'(upstream jedi#1990). Because_get_completions()only fell back to interpreter-based completion when the static path returned no completions — not when it raised — a jedi crash silently killed attribute completion for the affected variable, even though the interpreter fallback would have completed it fine from the runtime globals.This implements the fix approach @manzt suggested on the issue: treat a static-analysis crash like "no static completions", so the interpreter fallback still gets a chance to run. The crash is logged at DEBUG (matching the existing logging in
complete()).While restructuring, this also removes a redundant second
script.complete()call in_get_completions()—_get_completions_with_script()already runs the completion, so the previous code ran jedi's (potentially slow or crashing) analysis twice per request.Before: with
df_x = pl.concat([df_a, df_b])in a cell, typingdf_x.wiproduces no completion popup at all (silently, with nothing above DEBUG in the logs).After:
df_x.wicompletes (with_columns,with_row_index, ...) via the interpreter fallback.Tests: a unit test that simulates the static path raising (verifying the fallback runs), and a polars regression test with the exact repro from the issue (skipped when polars isn't installed).
📋 Pre-Review Checklist
✅ Merge Checklist