palantir / python-language-server

An implementation of the Language Server Protocol for Python
MIT License
2.6k stars 282 forks source link

added unwanted parenthesis for function parameters after completion #865

Open wztdream opened 3 years ago

wztdream commented 3 years ago

Hi, I use python-language-server (pyls for short) as backend in emacs for python-mode. But it seems, pyls will insert an extra parenthesis for function parameters after completion.

It does not happens each time, seems only with some keywords, for example threshold_abs, distance ect. Any way, this behaviour is un-reasonable I have to delete the parenthesis each time, it is quite noisy.

Bellow is an example

from skimage.feature import peak_local_max
local_maxi = peak_local_max(distance, thresho|ld_abs=) ;; cursor behind 'o' marked by '|', then press Enter, it will be:

local_maxi = peak_local_max(distance, threshold_abs=()|)

Here is the log: request sending to pyls

[Trace - 04:32:53 下午] Sending request 'textDocument/completion - (1239)'.
Params: {
  "textDocument": {
    "uri": "file:///home/wangzongtao/research/code/temp/learnng_skimage.py"
  },
  "position": {
    "line": 16,
    "character": 42
  },
  "context": {
    "triggerKind": 1
  }
}

response from pyls

[Trace - 04:32:53 下午] Received response 'textDocument/completion - (1239)' in 77ms.
Result: {
  "items": [
    {
      "insertText": "threshold_abs=()",       ;;; from the log we can see pyls inserted the extra parenthesis
      "sortText": "athreshold_abs=",
      "documentation": "NoneType()",
      "detail": "skimage.feature.peak.peak_local_max",
      "kind": 6,
      "label": "threshold_abs="
    },
    {
      "insertText": "threshold_rel=",
      "sortText": "athreshold_rel=",
      "documentation": "",
      "detail": "skimage.feature.peak.peak_local_max",
      "kind": 6,
      "label": "threshold_rel="
    }
  ],
  "isIncomplete": null
}