Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Completion result have "typeParameter" duplicates #273

Closed
masad-frost opened this issue Sep 30, 2022 · 5 comments · Fixed by #274
Closed

Completion result have "typeParameter" duplicates #273

masad-frost opened this issue Sep 30, 2022 · 5 comments · Fixed by #274
Milestone

Comments

@masad-frost
Copy link
Contributor

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

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

@masad-frost
Copy link
Contributor Author

I started seeing this when we enabled snippet completion

@masad-frost
Copy link
Contributor Author

masad-frost commented Sep 30, 2022

Chasing things down seems to be a regression caused by #246.

@llan-ml why is this desirable?
image

Or maybe @ccordoba12 has more input

@llan-ml
Copy link
Contributor

llan-ml commented 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
Copy link
Contributor Author

Do you have an example?

@ccordoba12
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants