Repository: spyder-ide/spyder

Issue:
TypeError when writing "np.sin(" in console
## Description

### What steps will reproduce the problem?

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

In console enter "np.sin("
and spyder encounters an internal problem.

### Traceback
```python-traceback
Traceback (most recent call last):
  File "/home/lenovo/projects/venv-spyder/lib/python3.10/site-packages/qtconsole/base_frontend_mixin.py", line 138, in _dispatch
    handler(msg)
  File "/home/lenovo/projects/venv-spyder/lib/python3.10/site-packages/spyder/plugins/ipythonconsole/widgets/help.py", line 170, in _handle_inspect_reply
    self._control.show_calltip(
  File "/home/lenovo/projects/venv-spyder/lib/python3.10/site-packages/spyder/widgets/mixins.py", line 603, in show_calltip
    self.calltip_widget.show_tip(point, text, [])
  File "/home/lenovo/projects/venv-spyder/lib/python3.10/site-packages/spyder/widgets/calltip.py", line 506, in show_tip
    point.setY(adjusted_point.y() - tip_height - padding)
TypeError: setY(self, int): argument 1 has unexpected type 'float'
```

## Versions

* Spyder version: 5.2.1 
* Python version: 3.10.1
* Qt version: 5.12.10
* PyQt5 version: 5.12.3
* Operating System: Linux 5.4.0-91-generic

### Dependencies

```
# Mandatory:
atomicwrites >=1.2.0          :  1.4.0 (OK)
chardet >=2.0.0               :  4.0.0 (OK)
cloudpickle >=0.5.0           :  2.0.0 (OK)
cookiecutter >=1.6.0          :  1.7.3 (OK)
diff_match_patch >=20181111   :  20200713 (OK)
intervaltree >=3.0.2          :  3.1.0 (OK)
IPython >=7.6.0               :  7.30.1 (OK)
jedi >=0.17.2;<0.19.0         :  0.18.1 (OK)
jellyfish >=0.7               :  0.8.9 (OK)
jsonschema >=3.2.0            :  4.3.2 (OK)
keyring >=17.0.0              :  23.4.0 (OK)
nbconvert >=4.0               :  6.3.0 (OK)
numpydoc >=0.6.0              :  1.1.0 (OK)
parso >=0.7.0;<0.9.0          :  0.8.3 (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.10.0 (OK)
pylint >=2.5.0                :  2.12.2 (OK)
pyls_spyder >=0.4.0           :  0.4.0 (OK)
pylsp >=1.3.2;<1.4.0          :  1.3.3 (OK)
pylsp_black >=1.0.0           :  1.0.1 (OK)
qdarkstyle =3.0.2             :  3.0.2 (OK)
qstylizer >=0.1.10            :  0.2.1 (OK)
qtawesome >=1.0.2             :  1.1.1 (OK)
qtconsole >=5.2.1;<5.3.0      :  5.2.2 (OK)
qtpy >=1.5.0                  :  2.0.0 (OK)
rtree >=0.9.7                 :  0.9.7 (OK)
setuptools >=49.6.0           :  58.1.0 (OK)
sphinx >=0.6.6                :  4.3.2 (OK)
spyder_kernels >=2.2.0;<2.3.0 :  2.2.0 (OK)
textdistance >=4.2.0          :  4.2.2 (OK)
three_merge >=0.1.1           :  0.1.1 (OK)
watchdog >=0.10.3             :  2.1.6 (OK)
xdg >=0.26                    :  0.27 (OK)
zmq >=17                      :  22.3.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 @khwp, thanks for reporting. This is a duplicate of issue #17120 and it'll be fixed in our next version (5.2.2), to be released soon.
In the meantime, please use Python 3.9 or an earlier version to avoid that issue.

Resolving patch:
diff --git a/spyder/plugins/editor/panels/linenumber.py b/spyder/plugins/editor/panels/linenumber.py
--- a/spyder/plugins/editor/panels/linenumber.py
+++ b/spyder/plugins/editor/panels/linenumber.py
@@ -182,7 +182,7 @@ def draw_linenumbers(self, painter):
 
             # Hide non-bold number
             painter.fillRect(
-                left, active_top, size.width(), size.height(),
+                int(left), active_top, int(size.width()), int(size.height()),
                 self.editor.sideareas_color
             )
 
diff --git a/spyder/widgets/calltip.py b/spyder/widgets/calltip.py
--- a/spyder/widgets/calltip.py
+++ b/spyder/widgets/calltip.py
@@ -187,8 +187,8 @@ def show_tip(self, point, tip, cursor=None, completion_doc=None):
             if os.name == 'nt':
                 padding = -7
             else:
-                padding = -4.5
-            point.setY(int(adjusted_point.y() - tip_height - padding))
+                padding = -4
+            point.setY(adjusted_point.y() - tip_height - padding)
 
         if horizontal == 'Left':
             point.setX(adjusted_point.x() - tip_width - padding)
@@ -500,9 +500,9 @@ def show_tip(self, point, tip, wrapped_tiplines):
             if os.name == 'nt':
                 padding = -7
             else:
-                padding = -4.5
-
+                padding = -4
             point.setY(adjusted_point.y() - tip_height - padding)
+
         if horizontal == 'Left':
             point.setX(adjusted_point.x() - tip_width - padding)
 


Test patch:
diff --git a/spyder/plugins/ipythonconsole/tests/test_ipythonconsole.py b/spyder/plugins/ipythonconsole/tests/test_ipythonconsole.py
--- a/spyder/plugins/ipythonconsole/tests/test_ipythonconsole.py
+++ b/spyder/plugins/ipythonconsole/tests/test_ipythonconsole.py
@@ -386,6 +386,9 @@ def test_get_calltips(ipyconsole, qtbot, function, signature, documentation):
 
 @flaky(max_runs=3)
 @pytest.mark.auto_backend
+@pytest.mark.skipif(
+    running_in_ci() and not os.name == 'nt',
+    reason="Times out on Linux and macOS")
 def test_auto_backend(ipyconsole, qtbot):
     """Test that the automatic backend was set correctly."""
     # Wait until the window is fully up
@@ -1839,14 +1842,16 @@ def test_startup_code_pdb(ipyconsole, qtbot):
 @flaky(max_runs=3)
 @pytest.mark.parametrize(
     "backend",
-    ['inline', 'qt5', 'tk', 'osx', ]
+    ['inline', 'qt5', 'tk', 'osx']
 )
 def test_pdb_eventloop(ipyconsole, qtbot, backend):
-    """Check if pdb works with every backend. (only testing 3)."""
+    """Check if setting an event loop while debugging works."""
     # Skip failing tests
-    if backend == 'tk' and (os.name == 'nt' or PY2):
+    if backend == 'tk' and os.name == 'nt':
+        return
+    if backend == 'osx' and sys.platform != "darwin":
         return
-    if backend == 'osx' and (sys.platform != "darwin" or PY2):
+    if backend == 'qt5' and not os.name == "nt" and running_in_ci():
         return
 
     shell = ipyconsole.get_current_shellwidget()
@@ -2057,7 +2062,10 @@ def test_breakpoint_builtin(ipyconsole, qtbot, tmpdir):
 
 @flaky(max_runs=3)
 @pytest.mark.auto_backend
-def test_shutdown_kernel(ipyconsole, qtbot, tmpdir):
+@pytest.mark.skipif(
+    running_in_ci() and not os.name == 'nt',
+    reason="Times out on Linux and macOS")
+def test_shutdown_kernel(ipyconsole, qtbot):
     """
     Check that the kernel is shutdown after creating plots with the
     automatic backend.
diff --git a/spyder/plugins/onlinehelp/tests/test_pydocgui.py b/spyder/plugins/onlinehelp/tests/test_pydocgui.py
--- a/spyder/plugins/onlinehelp/tests/test_pydocgui.py
+++ b/spyder/plugins/onlinehelp/tests/test_pydocgui.py
@@ -32,7 +32,7 @@ def pydocbrowser(qtbot):
     widget.resize(640, 480)
     widget.show()
 
-    with qtbot.waitSignal(widget.sig_load_finished, timeout=6000):
+    with qtbot.waitSignal(widget.sig_load_finished, timeout=20000):
         widget.initialize()
 
     qtbot.addWidget(widget)