Repository navigation
Closed
Milestone
Description
Completion items keep including duplicate items, but one of them has object at the end of the label.
Here is an example request, with document print
Expand to see request.
Trigger completion after `print` ```json { "method": "textDocument/completion", "params": { "textDocument": { "uri": "file:///home/user/dir/main.py" }, "position": { "line": 0, "character": 5 }, "context": { "triggerKind": 1 } }, "id": 1200384153, "jsonrpc": "2.0" } ```Expand to see result
{
"isIncomplete": false,
"items": [
{
"label": "print(values, sep, end, file, flush)",
"kind": 3,
"sortText": "aprint",
"insertText": "print",
"data": {
"doc_uri": "file:///home/runner/ExtraneousExcitedWebsites/main.py"
}
},
{
"label": "print(values, sep, end, file, flush) object",
"kind": 25,
"sortText": "aprint",
"insertText": "print",
"data": {
"doc_uri": "file:///home/runner/ExtraneousExcitedWebsites/main.py"
}
}
]
}Expand to see initialization options
```json { "method": "initialize", "params": { "capabilities": { "textDocument": { "synchronization": { "dynamicRegistration": true, "didSave": true }, "signatureHelp": { "dynamicRegistration": true, "signatureInformation": { "documentationFormat": [ "plaintext", "markdown" ] } }, "publishDiagnostics": { "relatedInformation": true }, "formatting": { "dynamicRegistration": true }, "documentSymbol": { "dynamicRegistration": true, "hierarchicalDocumentSymbolSupport": true, "symbolKind": { "valueSet": [ 18, 17, 5, 14, 9, 10, 22, 24, 8, 1, 12, 11, 20, 6, 2, 3, 19, 25, 4, 7, 15, 23, 26, 13 ] } }, "definition": { "dynamicRegistration": true }, "typeDefinition": { "dynamicRegistration": true }, "implementation": { "dynamicRegistration": true }, "references": { "dynamicRegistration": true }, "rename": { "dynamicRegistration": true, "prepareSupport": true }, "completion": { "dynamicRegistration": true, "completionItem": { "documentationFormat": [ "plaintext", "markdown" ], "snippetSupport": true } }, "codeAction": { "dynamicRegistration": true, "codeActionLiteralSupport": { "codeActionKind": { "valueSet": [ "", "quickfix", "refactor", "refactor.extract", "refactor.inline", "refactor.rewrite", "source", "source.organizeImports", "source.fixAll" ] } } }, "hover": { "dynamicRegistration": true, "contentFormat": [ "plaintext" ] } }, "workspace": { "applyEdit": true, "configuration": true, "executeCommand": { "dynamicRegistration": true }, "workspaceEdit": { "documentChanges": true, "resourceOperations": [ "create", "delete", "rename" ] } } }, "processId": null, "rootUri": "file:///home/runner/ExtraneousExcitedWebsites", "workspaceFolders": [ { "name": "file:///home/runner/ExtraneousExcitedWebsites", "uri": "file:///home/runner/ExtraneousExcitedWebsites" } ] }, "id": 79703483, "jsonrpc": "2.0" } ```I found this in the codebase
python-lsp-server/pylsp/plugins/jedi_completion.py
Lines 84 to 109 in 449d11a
| if include_class_objects: | |
| for i, c in enumerate(completions): | |
| if c.type == 'class': | |
| completion_dict = _format_completion( | |
| c, | |
| markup_kind=preferred_markup_kind, | |
| include_params=False, | |
| resolve=resolve_eagerly, | |
| resolve_label_or_snippet=(i < max_to_resolve) | |
| ) | |
| completion_dict['kind'] = lsp.CompletionItemKind.TypeParameter | |
| completion_dict['label'] += ' object' | |
| ready_completions.append(completion_dict) | |
| if include_function_objects: | |
| for i, c in enumerate(completions): | |
| if c.type == 'function': | |
| completion_dict = _format_completion( | |
| c, | |
| False, | |
| resolve=resolve_eagerly, | |
| resolve_label_or_snippet=(i < max_to_resolve) | |
| ) | |
| completion_dict['kind'] = lsp.CompletionItemKind.TypeParameter | |
| completion_dict['label'] += ' object' | |
| ready_completions.append(completion_dict) |
Not sure what is the point of it.
Some guidance and I'll happily fix the issue
Metadata
Metadata
Assignees
Labels
No labels
Activity
masad-frost commentedon Sep 30, 2022
I started seeing this when we enabled snippet completion
masad-frost commentedon Sep 30, 2022
Chasing things down seems to be a regression caused by #246.
@llan-ml why is this desirable?

Or maybe @ccordoba12 has more input
llan-ml commentedon Sep 30, 2022
@masad-frost In some usage cases such as python decorator and passing a function to another function, we only want to complete the name of a function, without including the parenthesis and function arguments.
masad-frost commentedon Sep 30, 2022
Do you have an example?
ccordoba12 commentedon Sep 30, 2022
I think we should disable this option by default so we don't show what appears to be two repeated entries in the completion widget of clients.