Repository: spyder-ide/spyder

Issue:
TypeError when trying to view output of Code Analysis pane
## Description

### What steps will reproduce the problem?

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

Run analyze in code analysis
Opening the output gave a message - "Spyder has encountered an internal problem"

### Traceback
```python-traceback
  File "/home/Saurabh/anaconda3/lib/python3.7/site-packages/spyder/plugins/pylint/widgets/pylintgui.py", line 308, in show_log
    readonly=True, size=(700, 500)).exec_()
TypeError: __init__() got an unexpected keyword argument 'size'
```

## Versions

* Spyder version: 4.1.1 
* Python version: 3.7.3
* Qt version: 5.9.6
* PyQt5 version: 5.9.2
* Operating System: Linux 4.19.0-1-amd64

### Dependencies

```

# Mandatory:
atomicwrites >=1.2.0           :  1.3.0 (OK)
chardet >=2.0.0                :  3.0.4 (OK)
cloudpickle >=0.5.0            :  1.2.1 (OK)
diff_match_patch >=20181111    :  20181111 (OK)
intervaltree                   :  None (OK)
IPython >=4.0                  :  7.6.1 (OK)
jedi =0.15.2                   :  0.15.2 (OK)
keyring                        :  None (OK)
nbconvert >=4.0                :  5.5.0 (OK)
numpydoc >=0.6.0               :  0.9.1 (OK)
parso =0.5.2                   :  0.5.2 (OK)
pexpect >=4.4.0                :  4.7.0 (OK)
pickleshare >=0.4              :  0.7.5 (OK)
psutil >=5.3                   :  5.6.3 (OK)
pygments >=2.0                 :  2.4.2 (OK)
pylint >=0.25                  :  2.3.1 (OK)
pyls >=0.31.9;<0.32.0          :  0.31.9 (OK)
qdarkstyle >=2.8               :  2.8 (OK)
qtawesome >=0.5.7              :  0.5.7 (OK)
qtconsole >=4.6.0              :  4.7.2 (OK)
qtpy >=1.5.0                   :  1.8.0 (OK)
rtree >=0.8.3                  :  0.9.3 (OK)
sphinx >=0.6.6                 :  2.1.2 (OK)
spyder_kernels >=1.9.0;<1.10.0 :  1.9.0 (OK)
watchdog                       :  None (OK)
xdg >=0.26                     :  0.26 (OK)
zmq >=17                       :  18.0.0 (OK)

# Optional:
cython >=0.21                  :  0.29.12 (OK)
matplotlib >=2.0.0             :  3.1.0 (OK)
numpy >=1.7                    :  1.16.4 (OK)
pandas >=0.13.1                :  0.24.2 (OK)
scipy >=0.17.0                 :  1.3.0 (OK)
sympy >=0.7.3                  :  1.4 (OK)
```



Discussion:
> Run analyze in code analysis

Please post the code you're trying to analyze so we can reproduce this in our end.
Please find the attached code with the screenshot of the error.

Saurabh
________________________________
From: Carlos Cordoba <notifications@github.com>
Sent: 30 March 2020 22:42
To: spyder-ide/spyder <spyder@noreply.github.com>
Cc: Saurabh Singh <saurabhsingh@iisc.ac.in>; Author <author@noreply.github.com>
Subject: Re: [spyder-ide/spyder] Ran code analyzed (#12052)


Run analyze in code analysis

Please post the code you're trying to analyze so we can reproduce this in our end.

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<https://github.com/spyder-ide/spyder/issues/12052#issuecomment-606126440>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AKMEUFECUBBTH2OJZB4FA43RKDHGJANCNFSM4LWXSE5Q>.


`"""Code for comparison of binomil and normal distribution."""
import numpy as np
from matplotlib import pyplot as plt
from N_choose_k import N_choose_k


total_moves = 100

step = 2
right_limit = total_moves+step
left_limit = -1*(right_limit-step)

resultant_right_moves = np.arange(left_limit, right_limit, step)
num_points = np.size(resultant_right_moves)

probability_right_move = 0.4
probabiilty_left_move = 1-probability_right_move

mean = total_moves*probability_right_move
std_dev = np.sqrt(total_moves*probability_right_move*probabiilty_left_move)

binomial_dist = np.zeros((num_points, 1))
normal_dist = np.zeros((num_points, 1))
counter = 0

for resultant_moves in resultant_right_moves:
    right_moves = total_moves/2+resultant_moves/2
    left_moves = total_moves/2-resultant_moves/2
    binomial_dist[counter] = N_choose_k(total_moves, int(right_moves)) * \
        (probability_right_move**right_moves) * \
        (probabiilty_left_move**left_moves)
    normal_dist[counter] = (1/(np.sqrt(2*np.pi)*std_dev)) * \
        np.exp((-1/(2*std_dev**2)) * (right_moves-mean) ** 2)
    counter += 1

plt.plot(resultant_right_moves, binomial_dist)
plt.plot(resultant_right_moves, normal_dist)
plt.xlabel('Resultant right moves')
plt.ylabel('Probability')
plt.legend(['Binomial', 'Normal'])
`
Thanks! I could reproduce it and it'll be fixed in our next version.

Resolving patch:
diff --git a/spyder/plugins/pylint/widgets/pylintgui.py b/spyder/plugins/pylint/widgets/pylintgui.py
--- a/spyder/plugins/pylint/widgets/pylintgui.py
+++ b/spyder/plugins/pylint/widgets/pylintgui.py
@@ -304,8 +304,14 @@ def save(self):
     @Slot()
     def show_log(self):
         if self.output:
-            TextEditor(self.output, title=_("Pylint output"), parent=self,
-                       readonly=True, size=(700, 500)).exec_()
+            output_dialog = TextEditor(
+                self.output,
+                title=_("Pylint output"),
+                parent=self,
+                readonly=True
+            )
+            output_dialog.resize(700, 500)
+            output_dialog.exec_()
 
     @Slot()
     def analyze_button_handler(self):


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
@@ -366,9 +366,9 @@ def test_sympy_client(ipyconsole, qtbot):
 @flaky(max_runs=3)
 @pytest.mark.cython_client
 @pytest.mark.skipif(
-    (os.name == 'nt' or
+    (not sys.platform.startswith('linux') or
      LooseVersion(ipy_release.version) == LooseVersion('7.11.0')),
-    reason="Doesn't work on Windows and fails for IPython 7.11.0")
+    reason="It only works reliably on Linux and fails for IPython 7.11.0")
 def test_cython_client(ipyconsole, qtbot):
     """Test that the Cython console is working correctly."""
     # Wait until the window is fully up
diff --git a/spyder/utils/tests/test_encoding.py b/spyder/utils/tests/test_encoding.py
--- a/spyder/utils/tests/test_encoding.py
+++ b/spyder/utils/tests/test_encoding.py
@@ -5,10 +5,12 @@
 
 """Tests for encodings.py"""
 
-import pytest
 import os
 import stat
 
+from flaky import flaky
+import pytest
+
 from spyder.utils.encoding import is_text_file, get_coding, write
 from spyder.py3compat import to_text_string, PY2
 
@@ -70,9 +72,7 @@ def test_permissions(tmpdir):
     assert old_mode == new_mode
 
 
-@pytest.mark.skipif(
-    PY2,
-    reason="It fails with very small differences on Python 2")
+@flaky(max_runs=10)
 def test_timestamp(tmpdir):
     """Check that the modification timestamp is preserved."""
     tmp_file = tmpdir.mkdir("timestamp").join('test_file.txt')
diff --git a/spyder/utils/tests/test_programs.py b/spyder/utils/tests/test_programs.py
--- a/spyder/utils/tests/test_programs.py
+++ b/spyder/utils/tests/test_programs.py
@@ -90,7 +90,7 @@ def test_run_python_script_in_terminal(scriptpath, qtbot):
     outfilepath = osp.join(scriptpath.dirname, 'out.txt')
     run_python_script_in_terminal(
         scriptpath.strpath, scriptpath.dirname, '', False, False, '')
-    qtbot.waitUntil(lambda: osp.exists(outfilepath), timeout=5000)
+    qtbot.waitUntil(lambda: osp.exists(outfilepath), timeout=10000)
     # Assert the result.
     with open(outfilepath, 'r') as txtfile:
         res = txtfile.read()
@@ -112,7 +112,7 @@ def test_run_python_script_in_terminal_blank_wdir(scriptpath_with_blanks,
     run_python_script_in_terminal(
         scriptpath_with_blanks.strpath, scriptpath_with_blanks.dirname,
         '', False, False, '')
-    qtbot.waitUntil(lambda: osp.exists(outfilepath), timeout=5000)
+    qtbot.waitUntil(lambda: osp.exists(outfilepath), timeout=10000)
     # Assert the result.
     with open(outfilepath, 'r') as txtfile:
         res = txtfile.read()
@@ -135,7 +135,7 @@ def test_run_python_script_in_terminal_with_wdir_empty(scriptpath, qtbot):
         outfilepath = osp.join(os.getcwd(), 'out.txt')
 
     run_python_script_in_terminal(scriptpath.strpath, '', '', False, False, '')
-    qtbot.waitUntil(lambda: osp.exists(outfilepath), timeout=5000)
+    qtbot.waitUntil(lambda: osp.exists(outfilepath), timeout=10000)
     # Assert the result.
     with open(outfilepath, 'r') as txtfile:
         res = txtfile.read()