Fix completer regressions - #15395
Open
krassowski wants to merge 2 commits into
Open
krassowski wants to merge 2 commits into
krassowski wants to merge 2 commits into
Conversation
|
This fixes the issues I was having, cheers. |
This branch has not been deployed
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.
References
Code changes
_strip_code_before_operator, sofor k in dgivesd, the waya + dalready did. Leaves outTrue,FalseandNone, which are values rather than boundaries._strip_code_before_operatorfromdict_key_matches, sox = d["<Tab>evaluatesdand notx = d.DataFramelines, and six further lines that use a keyword or an operator.User-facing changes
Dict key completion gave nothing whenever the subscript was not the first thing on the line.
x = d["<Tab>broke in 9.6,for k in d["<Tab>andlambda: d["<Tab>broke in 9.5, andd["bar"] * d["<Tab>never worked. The form people hit most isdf["k"] = df["Year<Tab>in pandas. With this PR all of them offer the keys again.Attribute completion shares that function, so it changes too when jedi is disabled.
for x in v.<Tab>,x = v if cond else v.<Tab>,del v.<Tab>,return v.<Tab>,yield v.<Tab>andx = q in v.<Tab>gave nothing before and now offer the attributes ofv.Before - no suggestions
After - suggestions
Performance
The text on the left of the subscript no longer reaches
_trim_expr, which drops it one character at a time. Microseconds per completion call, jedi disabled:d["compx = d["compfor k in d["compd["k"] = d["compThe saving grows with the length of the text before the subscript. Milliseconds for
x = [0, 1, ...] + d["comp:A line with an unclosed bracket still goes through the trim, because the tokenizer raises and the existing fallback runs.
print(0, 1, ..., d["compstays at 438 ms for 2403 characters.Alternatives considered
DICT_MATCHER_REGEXalone._trim_expr, and the regular expression stays as it is.for,lambda, the ternary, the comprehension andyieldbroken, because each is a valid expression or evaluates without raising.DICT_MATCHER_REGEXto capture only the subscripted expression.re.d[idx[0]][",nest["a"] ["b"] [",((d))["and any key holding a bracket, because a regular expression cannot match nested brackets.AI usage
Opus 5 ultra