Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions crates/ty_ide/src/completion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1411,6 +1411,13 @@ fn add_argument_completions<'db>(
let mut in_arguments = false;
for node in cursor.covering_node.ancestors() {
match node {
// Do not suggest argument completions in value positions for
// keyword arguments
ast::AnyNodeRef::Keyword(kw) => {
if kw.value.range().contains_range(cursor.range) {
return;
}
}
ast::AnyNodeRef::Arguments(_) => {
in_arguments = true;
}
Expand Down Expand Up @@ -8733,6 +8740,28 @@ re.match('', '', fla<CURSOR>
);
}

#[test]
fn call_keyword_argument_at_value() {
let builder = completion_test_builder(
"\
def bar(y_true,y_pred): ...

y_true = 1
y_pred = 2

bar(y_true=y<CURSOR>
",
);

assert_snapshot!(
builder.skip_keywords().skip_builtins().skip_auto_import().build().snapshot(),
@r###"
y_pred
y_true
"###
);
}

// Ideally, we should favour completions that are definitely raisable
// here. However, doing so would require `exception_ty` to fall back to
// token matching when AST-matching fails, making the function signficantly
Expand Down
Loading