Fix AssertionError when completing after dot followed by newline#2090
Closed
worksbyfriday wants to merge 1 commit intodavidhalter:masterfrom
Closed
Fix AssertionError when completing after dot followed by newline#2090worksbyfriday wants to merge 1 commit intodavidhalter:masterfrom
worksbyfriday wants to merge 1 commit intodavidhalter:masterfrom
Conversation
When completing `object. \n` at position (1, 8), jedi gets the leaf
at the cursor position, which is a newline node. The code only
checked for `endmarker` as a special case where the leaf isn't the
dot, but newline nodes need the same treatment.
Without this fix, the newline leaf gets passed through to
`_complete_trailer`, which eventually calls `_infer_node` on the
dot operator, triggering an AssertionError ("unhandled operator '.'").
The fix adds `newline` to the type check alongside `endmarker`.
Fixes davidhalter#1954
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Owner
|
Hi, I'm sorry to say this, but I decided to not work at all with AI generated pull requests/content. There are multiple reasons for this:
Thank you anyway for trying to contribute to Open Source. I would really appreciate if you avoid the usage of LLMs in my projects. It is obviously fine to use LLMs as a search/brainstorming tool with my projects, just don't use it to interact with me. PS: As a side note I want to mention that I'm probably not the only maintainer that is annoyed by LLM content. So you probably should not use LLMs for other repositories either. My initial emotions towards LLM content was way more negative than this message is and I assume other maintainers frequently have very negative feelings as well. |
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
Completing
object. \nat position (1, 8) crashes withAssertionError: unhandled operator '.' in ....Root cause
In
Completion._complete_python, the code gets the leaf at the cursor position. When there's a space + newline after the dot, the leaf is anewlinenode, not the dot. The code handlesendmarkeras a special case but notnewline, so the newline leaf falls through and the dot operator itself gets passed to_complete_trailer→_infer_node, which raisesAssertionErroron non-ellipsis operators.Fix
Added
"newline"to the type check alongside"endmarker"on line 293 ofcompletion.py:Test plan
test_whitespace_and_newline_after_dotregression testInterpreter,Script, and various whitespace patternsFixes #1954
🤖 Generated with Claude Code