Skip to content

fix(completion): fall back to interpreter completion when jedi static analysis raises - #10100

Merged
mscolnick merged 3 commits into
marimo-team:mainfrom
David-Wu1119:fix/completion-fallback-on-jedi-crash-10055
Jul 9, 2026
Merged

mscolnick merged 3 commits into
marimo-team:mainfrom
David-Wu1119:fix/completion-fallback-on-jedi-crash-10055

Conversation

@David-Wu1119

Copy link
Copy Markdown
Contributor

📝 Summary

Closes #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). 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

✅ Merge Checklist

  • I have read the contributor guidelines.
  • Documentation has been updated where applicable, including docstrings for API changes.
  • Tests have been added for the changes made.

Copilot AI review requested due to automatic review settings July 8, 2026 13:50
@vercel

vercel Bot commented Jul 8, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
marimo-docs Ready Ready Preview, Comment Jul 9, 2026 3:30pm

Request Review

@github-actions

github-actions Bot commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 Script completion 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 Light2Dark added the bug Something isn't working label Jul 8, 2026

@Light2Dark Light2Dark left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, just doing a pass to reduce comments.

Comment thread marimo/_runtime/complete.py Resolved
@Light2Dark

Copy link
Copy Markdown
Member

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]>
@David-Wu1119
David-Wu1119 force-pushed the fix/completion-fallback-on-jedi-crash-10055 branch from 0feeed2 to b79b42a Compare July 9, 2026 06:13
@David-Wu1119

Copy link
Copy Markdown
Contributor Author

recheck

@David-Wu1119

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

Co-authored-by: Shahmir Varqha <[email protected]>
mscolnick
mscolnick previously approved these changes Jul 9, 2026
@David-Wu1119

Copy link
Copy Markdown
Contributor Author

Signed — thanks for the review! The CLA check is green now.

@mscolnick
mscolnick merged commit f9b74fc into marimo-team:main Jul 9, 2026
36 checks passed
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.23.14-dev53

williambdean pushed a commit to williambdean/marimo that referenced this pull request Sep 6, 2026
… 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>

This branch was successfully deployed

1 active deployment
Preview — 4b086f11 Deployed Jul 9, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

5 participants