Repository: spyder-ide/spyder

Issue:
TypeError when using kite_tutorial
## Description

### What steps will reproduce the problem?

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

follow instructions in kite_tutorial.py

just type a in line 84 to try autocompletion fwhen  importing matplotlib

boom


### Traceback
```python-traceback
Traceback (most recent call last):
  File "/home/explore/miniconda3/envs/minecraft/lib/python3.6/site-packages/spyder/plugins/editor/widgets/codeeditor.py", line 4490, in _handle_completions
    if (len(text) >= self.automatic_completions_after_chars
TypeError: '>=' not supported between instances of 'int' and 'tuple'
```

## Versions

* Spyder version: 5.0.0 
* Python version: 3.6.13
* Qt version: 5.9.6
* PyQt5 version: 5.9.2
* Operating System: Linux 5.4.0-72-generic

### Dependencies

```

# Mandatory:
atomicwrites >=1.2.0          :  1.4.0 (OK)
chardet >=2.0.0               :  4.0.0 (OK)
cloudpickle >=0.5.0           :  1.6.0 (OK)
cookiecutter >=1.6.0          :  1.7.2 (OK)
diff_match_patch >=20181111   :  20200713 (OK)
intervaltree >=3.0.2          :  3.1.0 (OK)
IPython >=7.6.0               :  7.16.1 (OK)
jedi =0.17.2                  :  0.17.2 (OK)
jsonschema >=3.2.0            :  3.2.0 (OK)
keyring >=17.0.0              :  22.3.0 (OK)
nbconvert >=4.0               :  6.0.7 (OK)
numpydoc >=0.6.0              :  1.1.0 (OK)
parso =0.7.0                  :  0.7.0 (OK)
pexpect >=4.4.0               :  4.8.0 (OK)
pickleshare >=0.4             :  0.7.5 (OK)
psutil >=5.3                  :  5.8.0 (OK)
pygments >=2.0                :  2.8.1 (OK)
pylint >=1.0                  :  2.7.4 (OK)
pyls >=0.36.2;<1.0.0          :  0.36.2 (OK)
pyls_black >=0.4.6            :  0.4.6 (OK)
pyls_spyder >=0.3.2           :  0.3.2 (OK)
qdarkstyle =3.0.2             :  3.0.2 (OK)
qstylizer >=0.1.10            :  0.1.10 (OK)
qtawesome >=0.5.7             :  1.0.2 (OK)
qtconsole >=5.0.3             :  5.0.3 (OK)
qtpy >=1.5.0                  :  1.9.0 (OK)
rtree >=0.8.3                 :  0.9.7 (OK)
setuptools >=39.0.0           :  52.0.0.post20210125 (OK)
sphinx >=0.6.6                :  3.5.3 (OK)
spyder_kernels >=2.0.1;<2.1.0 :  2.0.1 (OK)
textdistance >=4.2.0          :  4.2.1 (OK)
three_merge >=0.1.1           :  0.1.1 (OK)
watchdog >=0.10.3;<2.0.0      :  1.0.2 (OK)
xdg >=0.26                    :  0.27 (OK)
zmq >=17                      :  20.0.0 (OK)

# Optional:
cython >=0.21                 :  None (NOK)
matplotlib >=2.0.0            :  None (NOK)
numpy >=1.7                   :  None (NOK)
pandas >=1.1.1                :  None (NOK)
scipy >=0.17.0                :  None (NOK)
sympy >=0.7.3                 :  None (NOK)
```



Discussion:
Hey @castorfou. thanks for reporting. We'll take a look at this problem.

@dalthviz, could you take a look at this? Thanks!
@ccordoba12 @castorfou I was able to replicate this but first I had to change the preferences to enable autocompletion results after just 1 character (the default is 3 I think):

![auto](https://user-images.githubusercontent.com/16781833/115279858-815c6c80-a147-11eb-8618-f1663b288a18.gif)


Note: The issue is actually caused not for an specific value but because of the change of the value. When changing it, it causes the `self.automatic_completions_after_chars` to become a tuple instead of just updating is number value (the tuple has the actual updated value inside). Strangely, after a Spyder restart the value is set properly

Resolving patch:
diff --git a/spyder/plugins/completion/plugin.py b/spyder/plugins/completion/plugin.py
--- a/spyder/plugins/completion/plugin.py
+++ b/spyder/plugins/completion/plugin.py
@@ -367,7 +367,7 @@ def after_configuration_update(self, options: List[Union[tuple, str]]):
             if opt in options:
                 opt_value = self.get_conf(opt, section=sec)
                 self.sig_editor_rpc.emit('call_all_editorstacks',
-                                         (method_name, (opt_value,)),
+                                         (method_name, (opt_value,),),
                                          {})
 
         # Update entries in the source menu
diff --git a/spyder/plugins/editor/plugin.py b/spyder/plugins/editor/plugin.py
--- a/spyder/plugins/editor/plugin.py
+++ b/spyder/plugins/editor/plugin.py
@@ -1603,7 +1603,7 @@ def file_renamed_in_data_in_editorstack(self, editorstack_id_str,
             if str(id(editorstack)) != editorstack_id_str:
                 editorstack.rename_in_data(original_filename, filename)
 
-    def call_all_editorstacks(self, method, *args, **kwargs):
+    def call_all_editorstacks(self, method, args, **kwargs):
         """Call a method with arguments on all editorstacks."""
         for editorstack in self.editorstacks:
             method = getattr(editorstack, method)


Test patch: