Repository: spyder-ide/spyder

Issue:
IndexError when autocompleting using Kite
## Description
Enable Kite.

![array](https://user-images.githubusercontent.com/22970578/66457578-a892a200-eaab-11e9-8512-b78084cd7c23.gif)

![subplots_err](https://user-images.githubusercontent.com/22970578/66457400-505ba000-eaab-11e9-9f31-4bdb9cc8d758.gif)


### What steps will reproduce the problem?

<!--- You can use Markdown here --->
1. Enable kite
2. Type Below
```python
from numpy import array

data = array([1,])
```

or

1. Enable kite
2. Type Below
```python
from matplotlib.pyplot import subplots

fig, ax = sub
```
3. select ...(\<nrows\>, \<ncols\>)

### Traceback
```python-traceback
  File "/home/ok97465/python/spyder/spyder/plugins/editor/widgets/codeeditor.py", line 1132, in process_signatures
    parameter_data = parameters[parameter_idx]
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ok97465/anaconda3/lib/python3.7/logging/__init__.py", line 1034, in emit
    msg = self.format(record)
  File "/home/ok97465/anaconda3/lib/python3.7/logging/__init__.py", line 880, in format
    return fmt.format(record)
  File "/home/ok97465/anaconda3/lib/python3.7/logging/__init__.py", line 619, in format
    record.message = record.getMessage()
  File "/home/ok97465/anaconda3/lib/python3.7/logging/__init__.py", line 380, in getMessage
    msg = msg % self.args
ValueError: incomplete format
Call stack:
  File "bootstrap.py", line 186, in <module>
    start.main()
  File "/home/ok97465/python/spyder/spyder/app/start.py", line 195, in main
    mainwindow.main()
  File "/home/ok97465/python/spyder/spyder/app/mainwindow.py", line 3628, in main
    mainwindow = run_spyder(app, options, args)
  File "/home/ok97465/python/spyder/spyder/app/mainwindow.py", line 3511, in run_spyder
    app.exec_()
  File "/home/ok97465/python/spyder/spyder/plugins/completion/plugin.py", line 138, in receive_response
    self.gather_and_send(request_responses)
  File "/home/ok97465/python/spyder/spyder/plugins/completion/plugin.py", line 189, in gather_and_send
    response_instance.handle_response(req_type, responses)
  File "/home/ok97465/python/spyder/spyder/plugins/editor/widgets/codeeditor.py", line 915, in handle_response
    handler(params)
  File "/home/ok97465/python/spyder/spyder/plugins/editor/widgets/codeeditor.py", line 1149, in process_signatures
    self.log_lsp_handle_errors("Error when processing signature")
  File "/home/ok97465/python/spyder/spyder/plugins/editor/widgets/codeeditor.py", line 946, in log_lsp_handle_errors
    logger.error('%', 1, stack_info=True)
Message: '%'
Arguments: (1,)
```

## Versions

* Spyder version: 4.0.0.dev0 cff20b038
* Python version: 3.7.3
* Qt version: 5.9.6
* PyQt5 version: 5.9.2
* Operating System: Linux 5.2.11-1-MANJARO

### Dependencies

```
cloudpickle >=0.5.0          :  1.0.0 (OK)
pygments >=2.0               :  2.4.0 (OK)
qtconsole >=4.5.5            :  4.5.5 (OK)
nbconvert >=4.0              :  5.5.0 (OK)
sphinx >=0.6.6               :  2.0.1 (OK)
pylint >=0.25                :  2.3.1 (OK)
psutil >=0.3                 :  5.6.2 (OK)
qtawesome >=0.5.7            :  0.5.7 (OK)
qtpy >=1.5.0                 :  1.5.0 (OK)
pickleshare >=0.4            :  0.7.5 (OK)
zmq >=17                     :  17.1.2 (OK)
chardet >=2.0.0              :  3.0.4 (OK)
numpydoc >=0.6.0             :  0.9.1 (OK)
spyder_kernels >=1.5.0;<2.0.0:  1.6.0.dev0 (OK)
qdarkstyle >=2.7             :  2.7 (OK)
atomicwrites >=1.2.0         :  1.2.1 (OK)
diff_match_patch >=20181111  :  20181111 (OK)
watchdog                     :  None (OK)
keyring                      :  None (OK)
pexpect >=4.4.0              :  4.7.0 (OK)
pympler                      :  None (OK)
sympy >=0.7.3                :  1.4 (OK)
cython >=0.21                :  0.29.8 (OK)
IPython >=4.0                :  7.8.0 (OK)
matplotlib >=2.0.0           :  3.1.1 (OK)
pandas >=0.13.1              :  0.24.2 (OK)
numpy >=1.7                  :  1.16.4 (OK)
scipy >=0.17.0               :  1.2.1 (OK)
pyls >=0.28.2;<0.29.0        :  0.28.3 (OK)
xdg >=0.26                   :  0.26 (OK)
rtree >=0.8.3                :  0.8.3 (OK)
```



Discussion:
@steff456, please take a look at this one.
This issue is not solved by #10411.

https://github.com/spyder-ide/spyder/blob/4208e6f6cf50c3c9ee695489047039fc18642790/spyder/plugins/editor/widgets/codeeditor.py#L1134-L1136

Sometimes the parameter_idx is greater than len(parameters) when using kite.
So perhaps it should be added to this conditional statement.
```python
if parameter_idx < len(parameters):
```
@dalthviz, please take a look at this one.

Resolving patch:
diff --git a/spyder/plugins/editor/widgets/codeeditor.py b/spyder/plugins/editor/widgets/codeeditor.py
--- a/spyder/plugins/editor/widgets/codeeditor.py
+++ b/spyder/plugins/editor/widgets/codeeditor.py
@@ -1130,8 +1130,7 @@ def process_signatures(self, params):
                 parameter_idx = signature_params['activeParameter']
                 parameters = signature_data['parameters']
                 parameter = None
-
-                if len(parameters) > 0:
+                if parameter_idx < len(parameters):
                     parameter_data = parameters[parameter_idx]
                     parameter = parameter_data['label']
 


Test patch: