Repository: spyder-ide/spyder

Issue:
Signature calltip doesn't work without automatic bracket completion (Kite example)
<!--- **PLEASE READ:** When submitting here, please ensure you've completed the following checklist and checked the boxes to confirm. Issue reports without it may be closed. Thanks! --->

### Issue Report Checklist

* [X] Searched the [issues page](https://github.com/spyder-ide/spyder/issues?q=is%3Aissue) for similar reports
* [X] Read the relevant sections of the [Spyder Troubleshooting Guide](https://github.com/spyder-ide/spyder/wiki/Troubleshooting-Guide-and-FAQ) and followed its advice
* [X] Reproduced the issue after updating with ``conda update spyder`` (or ``pip``, if not using Anaconda)
* [N/A] Could not reproduce inside ``jupyter qtconsole`` (if console-related)
* [X] Tried basic troubleshooting (if a bug/error)
    * [X] Restarted Spyder
    * [X] Reset preferences with ``spyder --reset``
    * [N/A] Reinstalled the latest version of [Anaconda](https://www.anaconda.com/download/)
    * [X] Tried the other applicable steps from the Troubleshooting Guide
* [X] Completed the **Problem Description**, **Steps to Reproduce** and **Version** sections below

## Problem Description

Kite function assist depends on automatic completion of brackets.  Turning this feature off stops function assist from working.

### What steps reproduce the problem?

1.  Open the kite tutorial.
2. Go to Tools...Preferences...Editor...Source Code and disable "Automatic insertion of parentheses, brackets and braces"
3. Go to the "Function signatures" section of the tutorial (section 2a)
4. Follow the instructions: add a `(` after `plt.plot`.

### What is the expected output? What do you see instead?

Expected output: documentation for function appears in a pop-up.
What actually happens: nothing.

Turning on "Automatic insertion of parenthesis, brackets and braces" makes it work, but I find that feature quite annoying as I instinctively close the brackets when I'm typing and hence end up with two close brackets.

### Paste Traceback/Error Below (if applicable)

Not applicable.

## Versions
<!--- You can get this information from Help > About Spyder...
or (if Spyder won't launch) the "conda list" command
from the Anaconda Prompt/Terminal/command line. --->

* Spyder version: 4.0.1
* Python version: 3.7.6 64-bit
* Qt version: 5.9.6
* PyQt version: 5.9.2
* Operating System name/version: Windows 10

### Dependencies
<!--- Please go to the menu entry Help > Dependencies,
press the Copy to clipboard button and paste below --->

```
atomicwrites >=1.2.0         :  1.3.0 (OK)
chardet >=2.0.0              :  3.0.4 (OK)
cloudpickle >=0.5.0          :  1.2.2 (OK)
diff_match_patch >=20181111  :  20181111 (OK)
intervaltree                 :  None (OK)
IPython >=4.0                :  7.11.1 (OK)
jedi =0.14.1                 :  0.14.1 (OK)
nbconvert >=4.0              :  5.6.1 (OK)
numpydoc >=0.6.0             :  0.9.2 (OK)
pexpect >=4.4.0              :  4.8.0 (OK)
pickleshare >=0.4            :  0.7.5 (OK)
psutil >=0.3                 :  5.6.7 (OK)
pygments >=2.0               :  2.5.2 (OK)
pylint >=0.25                :  2.4.4 (OK)
pyls >=0.31.2;<0.32.0        :  0.31.2 (OK)
zmq >=17                     :  18.1.0 (OK)
qdarkstyle >=2.7             :  2.7 (OK)
qtawesome >=0.5.7            :  0.6.0 (OK)
qtconsole >=4.6.0            :  4.6.0 (OK)
qtpy >=1.5.0                 :  1.9.0 (OK)
rtree >=0.8.3                :  0.8.3 (OK)
sphinx >=0.6.6               :  2.3.1 (OK)
spyder_kernels >=1.8.1;<2.0.0:  1.8.1 (OK)
watchdog                     :  None (OK)
cython >=0.21                :  0.29.14 (OK)
matplotlib >=2.0.0           :  3.1.1 (OK)
numpy >=1.7                  :  1.18.1 (OK)
pandas >=0.13.1              :  0.25.3 (OK)
scipy >=0.17.0               :  1.3.2 (OK)
sympy >=0.7.3                :  1.5.1 (OK)

```



Discussion:
@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
@@ -3811,7 +3811,7 @@ def insert_text(event):
                         self._start_completion_timer()
             else:
                 self.do_completion(automatic=True)
-        elif (text != '(' and text in self.signature_completion_characters and
+        elif (text in self.signature_completion_characters and
                 not self.has_selected_text()):
             self.insert_text(text)
             self.request_signature()


Test patch:
diff --git a/spyder/plugins/editor/widgets/tests/test_hints_and_calltips.py b/spyder/plugins/editor/widgets/tests/test_hints_and_calltips.py
--- a/spyder/plugins/editor/widgets/tests/test_hints_and_calltips.py
+++ b/spyder/plugins/editor/widgets/tests/test_hints_and_calltips.py
@@ -15,6 +15,10 @@
 from qtpy.QtGui import QTextCursor
 import pytest
 
+# Local imports
+from spyder.plugins.editor.extensions.closebrackets import (
+        CloseBracketsExtension)
+
 # Constants
 PY2 = sys.version[0] == '2'
 TEST_SIG = 'some_function(foo={}, hello=None)'
@@ -80,6 +84,28 @@ def test_get_calltips(qtbot, lsp_codeeditor, params):
     code_editor.moveCursor(QTextCursor.End)
 
     code_editor.calltip_widget.hide()
+
+    # Test with brackets autocompletion enable/disable
+    bracket_extension = code_editor.editor_extensions.get(
+        CloseBracketsExtension)
+
+    # Bracket autocompletion enabled
+    with qtbot.waitSignal(code_editor.sig_signature_invoked,
+                          timeout=30000) as blocker:
+        qtbot.keyPress(code_editor, Qt.Key_ParenLeft, delay=1000)
+
+        # This is needed to leave time for the calltip to appear
+        # and make the tests succeed
+        qtbot.wait(2000)
+
+        args = blocker.args
+        print('args:', [args])
+        output_text = args[0]['signatures']['label']
+        assert expected_output_text in output_text
+        code_editor.calltip_widget.hide()
+
+    # Bracket autocompletion disabled
+    bracket_extension.enable = False
     with qtbot.waitSignal(code_editor.sig_signature_invoked,
                           timeout=30000) as blocker:
         qtbot.keyPress(code_editor, Qt.Key_ParenLeft, delay=1000)
@@ -94,6 +120,9 @@ def test_get_calltips(qtbot, lsp_codeeditor, params):
         assert expected_output_text in output_text
         code_editor.calltip_widget.hide()
 
+    # Set bracket autocomplete to default value
+    bracket_extension.enable = True
+
 
 @pytest.mark.slow
 @pytest.mark.second