Repository: spyder-ide/spyder

Issue:
Error when type in "for i in range()" with Kite enabled
## Description

### What steps will reproduce the problem?

<!--- You can use Markdown here --->

From the master respository, run spyder via "python bootstrap.py", 
type in `for i in range()`. I've deleted the configuration directory "c:\Users\xxx\.spyder-py3-dev\"

But no error occurs if spyder is started via "python bootstrap.py --debug".

### Traceback
```python-traceback
  File "C:\python\project\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 "c:\anaconda3\lib\logging\__init__.py", line 1025, in emit
    msg = self.format(record)
  File "c:\anaconda3\lib\logging\__init__.py", line 869, in format
    return fmt.format(record)
  File "c:\anaconda3\lib\logging\__init__.py", line 608, in format
    record.message = record.getMessage()
  File "c:\anaconda3\lib\logging\__init__.py", line 369, in getMessage
    msg = msg % self.args
ValueError: incomplete format
Call stack:
  File "bootstrap.py", line 186, in <module>
    start.main()
  File "C:\python\project\spyder\spyder\app\start.py", line 195, in main
    mainwindow.main()
  File "C:\python\project\spyder\spyder\app\mainwindow.py", line 3646, in main
    mainwindow = run_spyder(app, options, args)
  File "C:\python\project\spyder\spyder\app\mainwindow.py", line 3529, in run_spyder
    app.exec_()
  File "C:\python\project\spyder\spyder\plugins\completion\plugin.py", line 138, in receive_response
    self.gather_and_send(request_responses)
  File "C:\python\project\spyder\spyder\plugins\completion\plugin.py", line 189, in gather_and_send
    response_instance.handle_response(req_type, responses)
  File "C:\python\project\spyder\spyder\plugins\editor\widgets\codeeditor.py", line 915, in handle_response
    handler(params)
  File "C:\python\project\spyder\spyder\plugins\editor\widgets\codeeditor.py", line 1149, in process_signatures
    self.log_lsp_handle_errors("Error when processing signature")
  File "C:\python\project\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 1d9deb0a6
* Python version: 3.7.4
* Qt version: 5.9.7
* PyQt5 version: 5.9.2
* Operating System: Windows 10

### Dependencies

```
cloudpickle >=0.5.0          :  1.2.2 (OK)
pygments >=2.0               :  2.4.2 (OK)
qtconsole >=4.5.5            :  4.5.5 (OK)
nbconvert >=4.0              :  5.6.0 (OK)
sphinx >=0.6.6               :  2.2.1 (OK)
pylint >=0.25                :  2.4.2 (OK)
psutil >=0.3                 :  5.6.3 (OK)
qtawesome >=0.5.7            :  0.6.0 (OK)
qtpy >=1.5.0                 :  1.9.0 (OK)
pickleshare >=0.4            :  0.7.5 (OK)
zmq >=17                     :  18.1.0 (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.3.0 (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                :  None (NOK)
cython >=0.21                :  0.29.13 (OK)
IPython >=4.0                :  7.8.0 (OK)
matplotlib >=2.0.0           :  3.1.1 (OK)
pandas >=0.13.1              :  0.25.1 (OK)
numpy >=1.7                  :  1.17.1 (OK)
scipy >=0.17.0               :  1.3.1 (OK)
pyls >=0.28.2;<0.29.0        :  0.28.3 (OK)
rtree >=0.8.3                :  0.8.3 (OK)
```



Discussion:
Thanks for reporting. Are you using Kite?
By the way, I can't reproduce this problem on Linux. @dalthviz, can you reproduce this on Windows?
@ccordoba12  Yes, I'm using Kite. The problem seems gone if Kite is disabled.
@ccordoba12 @gepcel I can reproduce this, and yep it seems related with a Kite Completion (a missing validation checking if the signature has parameters)

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
@@ -1129,10 +1129,13 @@ def process_signatures(self, params):
 
                 parameter_idx = signature_params['activeParameter']
                 parameters = signature_data['parameters']
-                parameter_data = parameters[parameter_idx]
+                parameter = None
+
+                if len(parameters) > 0:
+                    parameter_data = parameters[parameter_idx]
+                    parameter = parameter_data['label']
 
                 signature = signature_data['label']
-                parameter = parameter_data['label']
 
                 # This method is part of spyder/widgets/mixins
                 self.show_calltip(


Test patch: