Skip to content
Open
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions pylsp/plugins/jedi_completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"keyword": lsp.CompletionItemKind.Keyword,
"property": lsp.CompletionItemKind.Property, # added in Jedi 0.18
"statement": lsp.CompletionItemKind.Variable,
"string": lsp.CompletionItemKind.Value,
}

# Types of parso nodes for which snippet is not included in the completion
Expand Down
19 changes: 19 additions & 0 deletions test/plugins/test_completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,25 @@ def test_jedi_completion_type(case, config, workspace):
assert items[case.label]["kind"] == case.expected


@pytest.mark.parametrize("enum_name", ["Kind", "Foo"])
def test_jedi_dictionary_key_completion_type(enum_name, config, workspace):
source = (
"from enum import Enum\n"
f"class {enum_name}(str, Enum):\n"
" something = 'value'\n"
"def foo():\n"
f" a = {{'some_key': {enum_name}.something}}\n"
" a['some"
)
doc = Document(DOC_URI, workspace, source)
items = pylsp_jedi_completions(config, doc, {"line": 5, "character": 11})

assert items
item = next(item for item in items if item["label"].strip("'") == "some_key")
assert item["kind"] == lsp.CompletionItemKind.Value
assert item["insertText"] == item["label"]


def test_jedi_completion(config, workspace) -> None:
# Over 'i' in os.path.isabs(...)
com_position = {"line": 1, "character": 15}
Expand Down