internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: spyder-ide/spyder

Issue:
TypeError in kite client
## Description

### What steps will reproduce the problem?

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

when i move mouse the error rasises
kite is installed
linux ubuntu 18

### Traceback
```python-traceback
  File "/home/mehrad/P374/lib/python3.7/site-packages/spyder/plugins/completion/kite/client.py", line 135, in perform_request
TypeError: 'NoneType' object is not subscriptable
WARNING:spyder.widgets.github.backend:Failed to send bug report on Github. response={'code': 401, 'json': {'message': 'Bad credentials', 'documentation_url': 'https://developer.github.com/v3'}}
WARNING:spyder.widgets.github.backend:Failed to send bug report on Github. response={'code': 401, 'json': {'message': 'Bad credentials', 'documentation_url': 'https://developer.github.com/v3'}}
WARNING:spyder.widgets.github.backend:Failed to send bug report on Github. response={'code': 401, 'json': {'message': 'Bad credentials', 'documentation_url': 'https://developer.github.com/v3'}}
```

## Versions

* Spyder version: 4.0.0b4 
* Python version: 3.7.4
* Qt version: 5.12.4
* PyQt5 version: 5.12.3
* Operating System: Linux 5.0.0-25-generic

### Dependencies

```
pygments >=2.0    :  2.4.2 (OK)
qdarkstyle >=2.6.4:  2.7 (OK)
sphinx >=0.6.6    :  2.2.0 (OK)
psutil >=0.3      :  5.6.3 (OK)
pyls >=0.27.0     :  0.28.3 (OK)
nbconvert >=4.0   :  5.6.0 (OK)
pandas >=0.13.1   :  0.25.1 (OK)
numpy >=1.7       :  1.17.2 (OK)
sympy >=0.7.3     :  None (NOK)
cython >=0.21     :  0.29.13 (OK)
qtconsole >=4.5.2 :  4.5.5 (OK)
IPython >=4.0     :  7.8.0 (OK)
matplotlib >=2.0.0:  3.1.1 (OK)
pylint >=0.25     :  2.3.1 (OK)
```



Discussion:
@andfoy, I think this is valid. In line 104 below (which was line 135 in beta4):

https://github.com/spyder-ide/spyder/blob/08f04cfb50cfb74e8120e8ac91f2f5e510999b5a/spyder/plugins/completion/kite/client.py#L100-L106

you're trying to apply a function to `response` when `response` can be `None` (as line 105 shows).

This should be an easy fix, but I'm unsure what do to do, so please take a look at it.
@steff456, please ask @andfoy how to solve this one and create a PR for it.

Resolving patch:
diff --git a/spyder/plugins/completion/kite/client.py b/spyder/plugins/completion/kite/client.py
--- a/spyder/plugins/completion/kite/client.py
+++ b/spyder/plugins/completion/kite/client.py
@@ -101,6 +101,7 @@ def perform_request(self, req_id, method, params):
             if method in self.handler_registry:
                 converter_name = self.handler_registry[method]
                 converter = getattr(self, converter_name)
-                response = converter(response)
+                if response is not None:
+                    response = converter(response)
             if response is not None:
                 self.sig_response_ready.emit(req_id, response)


Test patch:
Repository: spyder-ide/spyder

Issue:
Minimal pyxdg version not set in setup.py
Hey there,

After installing spyder4.0b5, it complained about the xdg version (which was 0.25 in my case, and it wanted at least 0.26).

Maybe this could be set in the setup.py:

https://github.com/spyder-ide/spyder/blob/ac379b34028e009d523c00f7394489469e35a0ab/setup.py#L236

Cheers,
Sebastian


Discussion:
@steff456, please take care of this one by adding 0.26 as the minimal required version in our `setup.py`.

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -233,7 +233,7 @@ def run(self):
     'pexpect',
     'paramiko;platform_system=="Windows"',
     # Required for accesing xdg spec on Linux
-    'pyxdg;platform_system=="Linux"',
+    'pyxdg>=0.26;platform_system=="Linux"',
     'pympler'
 ]
 


Test patch:
Repository: spyder-ide/spyder

Issue:
Big toolip when using kite
## Description
![spyder_tip_error_with_kite](https://user-images.githubusercontent.com/22970578/66701391-f40cb080-ed36-11e9-9068-21a90aba2f5c.gif)


### What steps will reproduce the problem?

<!--- You can use Markdown here --->

1. Enable Kite

2. Type below

```python
from numpy import linspace

data = linspace(1, 2)

dat
```
3. Wait completion list



## Versions

* Spyder version: 4.0.0.dev0 cff20b038
* Python version: 3.7.3
* Qt version: 5.9.6
* PyQt5 version: 5.9.2
* Operating System: Windows 10

### Dependencies

```
cloudpickle >=0.5.0          :  1.2.1 (OK)
pygments >=2.0               :  2.4.2 (OK)
qtconsole >=4.5.5            :  4.5.5 (OK)
nbconvert >=4.0              :  5.5.0 (OK)
sphinx >=0.6.6               :  2.1.2 (OK)
pylint >=0.25                :  2.3.1 (OK)
psutil >=0.3                 :  5.6.3 (OK)
qtawesome >=0.5.7            :  0.5.7 (OK)
qtpy >=1.5.0                 :  1.8.0 (OK)
pickleshare >=0.4            :  0.7.5 (OK)
zmq >=17                     :  18.0.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                :  1.4 (OK)
cython >=0.21                :  0.29.12 (OK)
IPython >=4.0                :  7.6.1 (OK)
matplotlib >=2.0.0           :  3.1.0 (OK)
pandas >=0.13.1              :  0.24.2 (OK)
numpy >=1.7                  :  1.16.4 (OK)
scipy >=0.17.0               :  1.2.1 (OK)
pyls >=0.28.2;<0.29.0        :  0.28.3 (OK)
rtree >=0.8.3                :  0.8.3 (OK)
```



Discussion:
@dalthviz, please take a look at this one.

Resolving patch:
diff --git a/spyder/widgets/mixins.py b/spyder/widgets/mixins.py
--- a/spyder/widgets/mixins.py
+++ b/spyder/widgets/mixins.py
@@ -453,13 +453,15 @@ def _check_signature_and_format(self, signature_or_text, parameter=None,
 
         if language == 'python':
             open_func_char = '('
+            end_func_char_line = [')', ',']
             idx = signature_or_text.find(open_func_char)
             inspect_word = signature_or_text[:idx]
             name_plus_char = inspect_word + open_func_char
 
             # Signature type
             count = signature_or_text.count(name_plus_char)
-            has_signature = open_func_char in lines[0]
+            has_signature = (open_func_char in lines[0]
+                             and lines[0][-1] in end_func_char_line)
             if len(lines) > 1:
                 has_multisignature = count > 1 and name_plus_char in lines[1]
             else:


Test patch:
Repository: spyder-ide/spyder

Issue:
Editor plugin not raised after selecting file in Switcher
This is relevant for Spyder 4.0.0b5 and master.

As I remember (which may well not be correct), in the old file switcher (before #10060), when selecting a file which is opened in the editor, the editor plugin is raised to the front. This normally does not matter, because the editor plugin occupies a space all by itself. However, it becomes noticeable if the notebook plugin is installed, because now the switcher can be used to switch between files in the editor and the notebook plugin. I think that the editor plugin should raise itself if a file from the editor is selected in the switcher.


Discussion:
I agree, thanks for reporting this @jitseniesen!

Resolving patch:
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
@@ -1055,6 +1055,7 @@ def register_plugin(self):
 
         # Add modes to switcher
         self.switcher_manager = EditorSwitcherManager(
+            self,
             self.main.switcher,
             lambda: self.get_current_editor(),
             lambda: self.get_current_editorstack(),
diff --git a/spyder/plugins/editor/utils/switcher.py b/spyder/plugins/editor/utils/switcher.py
--- a/spyder/plugins/editor/utils/switcher.py
+++ b/spyder/plugins/editor/utils/switcher.py
@@ -99,8 +99,8 @@ class EditorSwitcherManager(object):
     LINE_MODE = ':'
     FILES_MODE = ''
 
-    def __init__(self, switcher_instance, get_codeeditor, get_editorstack,
-                 section=_("Editor")):
+    def __init__(self, plugin, switcher_instance, get_codeeditor,
+                 get_editorstack, section=_("Editor")):
         """
         'get_codeeditor' and 'get_editorstack' params should be callables
         to get the current CodeEditor or EditorStack instance as needed.
@@ -108,6 +108,7 @@ def __init__(self, switcher_instance, get_codeeditor, get_editorstack,
             current_codeeditor = get_codeditor()
             current_editorstack = get_editorstack()
         """
+        self._plugin = plugin
         self._switcher = switcher_instance
         self._editor = get_codeeditor
         self._editorstack = get_editorstack
@@ -231,6 +232,7 @@ def handle_switcher_selection(self, item, mode, search_text):
             # Each plugin that wants to attach to the switcher should do this?
             if item.get_section() == self._section:
                 self.editor_switcher_handler(data)
+                self._plugin.switch_to_plugin()
 
     def handle_switcher_text(self, search_text):
         """Handle switcher search text for line mode."""


Test patch:
Repository: spyder-ide/spyder

Issue:
Syntax coloring  incorrect with import as statements
## Description

### What steps will reproduce the problem?

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

Enter the following in an editor

    import subprocess as subp


Using the dark scheme, the 'import' and 'as' are purple, and 'subprocess' is white, as expected. However, the first 3 characters of 'subp' are purple, and the p in it is white.

This seems consistent - the first 4 characters after 'as' are purple. To illustrate this, put the cursor in between 'as' and 'subp' and insert a space. Now only 'su' is purple, and 'bp' is white. 



## Versions

* Spyder version: 4.0.0b5 
* Python version: 3.7.3
* Qt version: 5.9.6
* PyQt5 version: 5.9.2
* Operating System: Windows 7

### 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.0 (OK)
pylint >=0.25                :  2.3.1 (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.5.0 (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                :  1.4 (OK)
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.16.5 (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:
I can reproduce this

![image](https://user-images.githubusercontent.com/3627835/66158932-910b7300-e5ec-11e9-827e-2955e714191b.png)

@steff456, please take a look at this one. It's probably cause by an error in our syntax highlighter.

Resolving patch:
diff --git a/spyder/utils/syntaxhighlighters.py b/spyder/utils/syntaxhighlighters.py
--- a/spyder/utils/syntaxhighlighters.py
+++ b/spyder/utils/syntaxhighlighters.py
@@ -487,7 +487,7 @@ class PythonSH(BaseSH):
     add_kw = ['async', 'await']
     PROG = re.compile(make_python_patterns(additional_keywords=add_kw), re.S)
     IDPROG = re.compile(r"\s+(\w+)", re.S)
-    ASPROG = re.compile(r".*?\b(as)\b")
+    ASPROG = re.compile(r"\b(as)\b")
     # Syntax highlighting states (from one text block to another):
     (NORMAL, INSIDE_SQ3STRING, INSIDE_DQ3STRING,
      INSIDE_SQSTRING, INSIDE_DQSTRING,


Test patch:
Repository: spyder-ide/spyder

Issue:
The kite logo on the status bar is pixelated on retina display:
The kite logo on the status bar is pixelated on retina display:

<img width="391" alt="Screen Shot 2019-10-17 at 11 23 07" src="https://user-images.githubusercontent.com/3627835/67028195-84008080-f0d0-11e9-882a-e20fd893f62e.png">




Discussion:
@goanpeca, please take care of this one.

Resolving patch:
diff --git a/spyder/utils/icon_manager.py b/spyder/utils/icon_manager.py
--- a/spyder/utils/icon_manager.py
+++ b/spyder/utils/icon_manager.py
@@ -401,22 +401,10 @@ def icon(name, scale_factor=None, resample=False, icon_path=None):
         return icon if icon is not None else QIcon()
 
 
-def get_kite_icon(scale_factor=0.85):
+def get_kite_icon():
     """Return the Kite logo taking into account the theme of the interface."""
-    icon_path = 'kite_light.svg'
-    if is_dark_interface():
-        icon_path = 'kite_dark.svg'
-    pixmap = QPixmap(get_image_path(icon_path))
-    if scale_factor is not None:
-        pixmap_height = 16 * scale_factor
-        pixmap_width = 16 * scale_factor
-        pixmap = pixmap.scaled(
-            pixmap_width,
-            pixmap_height,
-            aspectRatioMode=Qt.KeepAspectRatio,
-            transformMode=Qt.SmoothTransformation)
-    kite_icon = QIcon(pixmap)
-    return kite_icon
+    icon_path = 'kite_dark.svg' if is_dark_interface() else 'kite_light.svg'
+    return QIcon(get_image_path(icon_path))
 
 
 def get_icon_by_extension_or_type(fname, scale_factor):
diff --git a/spyder/widgets/status.py b/spyder/widgets/status.py
--- a/spyder/widgets/status.py
+++ b/spyder/widgets/status.py
@@ -41,7 +41,7 @@ def __init__(self, parent, statusbar, icon=None):
         self._icon = None
         self._pixmap = None
         self._icon_size = QSize(16, 16)  # Should this be adjustable?
-        self.label_icon = QLabel() if icon is not None else None
+        self.label_icon = QLabel()
         self.label_value = QLabel()
 
         # Widget setup
@@ -54,8 +54,11 @@ def __init__(self, parent, statusbar, icon=None):
 
         # Layout
         layout = QHBoxLayout()
-        if icon is not None:
-            layout.addWidget(self.label_icon)
+        layout.setSpacing(0)  # Reduce space between icon and label
+        layout.addWidget(self.label_icon)
+        self.label_icon.setVisible(icon is not None)
+
+
         layout.addWidget(self.label_value)
         layout.addSpacing(20)
 
@@ -72,6 +75,7 @@ def __init__(self, parent, statusbar, icon=None):
     # ------------------------------------------------------------------------
     def set_icon(self, icon):
         """Set the icon for the status bar widget."""
+        self.label_icon.setVisible(icon is not None)
         if icon is not None and isinstance(icon, QIcon):
             self._icon = icon
             self._pixmap = icon.pixmap(self._icon_size)


Test patch:
Repository: spyder-ide/spyder

Issue:
Can't click in tooltip because it disappears
## Description

### What steps will reproduce the problem?

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

In beta relase 4, when you hover over a symbol briefly in the editor a tooltip appears. At the bottom it states "Click anywhere in this tooltip for additional help". If you move the mouse to try to click in the in the tooltip the tooltip disappears due to the mouse move, making it impossible to click inside it. 





## Versions

* Spyder version: 4.0.0b4 
* Python version: 3.7.3
* Qt version: 5.9.6
* PyQt5 version: 5.9.2
* Operating System: Windows 7

### Dependencies

```
pygments >=2.0    :  2.4.2 (OK)
qdarkstyle >=2.6.4:  2.7 (OK)
sphinx >=0.6.6    :  2.1.2 (OK)
pyls >=0.27.0     :  0.28.2 (OK)
nbconvert >=4.0   :  5.5.0 (OK)
pandas >=0.13.1   :  None (NOK)
numpy >=1.7       :  1.16.4 (OK)
sympy >=0.7.3     :  None (NOK)
cython >=0.21     :  None (NOK)
qtconsole >=4.5.2 :  4.5.4 (OK)
IPython >=4.0     :  7.8.0 (OK)
matplotlib >=2.0.0:  3.1.1 (OK)
pylint >=0.25     :  2.3.1 (OK)
```



Discussion:
@dalthviz  could you check this? Might be related to what I saw earleir
Repinging @dalthviz here because the above ping was wrong.
@goanpeca @ccordoba12 I will check, but probably is related to the behavior @goanpeca experienced when testing PR #9897 (I added a fix there but I'm not sure if that covers the case for the tooltip being shown without the completion widget). Should I do the fix for this issue on that PR?
>Should I do the fix for this issue on that PR?

Hmm let's try to find a fix on a separate PR.
@goanpeca, what's exactly happening here?
Under some circumstances the tooltip dialog might hide when trying to click on it because there is a small gap between the bound box that triggers the tooltip and the tooltip itslef. It does not happen all the time but it seems it might be for win 7 ?   

Resolving patch:
diff --git a/spyder/widgets/mixins.py b/spyder/widgets/mixins.py
--- a/spyder/widgets/mixins.py
+++ b/spyder/widgets/mixins.py
@@ -95,7 +95,8 @@ def _calculate_position(self, at_line=None, at_point=None):
 
         if at_point is not None:
             # Showing tooltip at point position
-            cx, cy = at_point.x(), at_point.y()
+            margin = (self.document().documentMargin() / 2) + 1
+            cx, cy = at_point.x() - margin, at_point.y() - margin
         elif at_line is not None:
             # Showing tooltip at line
             cx = 5


Test patch:
Repository: spyder-ide/spyder

Issue:
Kite tutorial keeps trying to reload tutorial file
## Description

### What steps will reproduce the problem?

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

If you follow the instructions in kite_tutorial.py as soon as you accept any of the autocomplete spyder pops up a dialog box stating the file has been changed and do you want to reload it. If you say yes it reloads your file. If you say no it sometimes causes Spyder to crash (this is hard to duplicate for me). By crash I mean exit to Windows, popping up the 'do you want to debug Windows dialog, not catch an exception.

I also think the text is incorrect in 1b. The instructions have you try to autocomplete 'pyplot as plt', but the code already reads "import matplotlib.pyplot as plt" - maybe that got inserted by me one time while trying to reproduce the crash?





## Versions

* Spyder version: 4.0.0rc1 
* Python version: 3.7.3
* Qt version: 5.9.6
* PyQt5 version: 5.9.2
* Operating System: Windows 7

### 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.3 (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.7.0;<2.0.0:  1.7.0 (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                :  1.4 (OK)
cython >=0.21                :  0.29.13 (OK)
IPython >=4.0                :  7.9.0 (OK)
matplotlib >=2.0.0           :  3.1.1 (OK)
pandas >=0.13.1              :  0.25.2 (OK)
numpy >=1.7                  :  1.17.2 (OK)
scipy >=0.17.0               :  1.3.1 (OK)
pyls >=0.29.3;<0.30.0        :  0.29.3 (OK)
rtree >=0.8.3                :  0.8.3 (OK)
```



Discussion:
@dalthviz, please take a look at this one.

Resolving patch:
diff --git a/spyder/plugins/completion/kite/plugin.py b/spyder/plugins/completion/kite/plugin.py
--- a/spyder/plugins/completion/kite/plugin.py
+++ b/spyder/plugins/completion/kite/plugin.py
@@ -167,7 +167,8 @@ def _kite_onboarding(self):
         """Request the onboarding file."""
         # No need to check installed status,
         # since the get_onboarding_file call fails fast.
-        self.client.sig_perform_onboarding_request.emit()
+        if self._show_onboarding:
+            self.client.sig_perform_onboarding_request.emit()
 
     @Slot(str)
     def _show_onboarding_file(self, onboarding_file):


Test patch:
Repository: spyder-ide/spyder

Issue:
Toolbar tooltips are not updated correctly after a change is made to the shortcuts
## Problem Description

### What steps reproduce the problem?

1.  Change a shortcut in the `Keyboard shortcuts preferences` and click `Apply`
2. The new shortcut is appended to the tooltip, without removing the old shortcut

![shortcut_tooltips](https://user-images.githubusercontent.com/10170372/68968170-f0de6780-07af-11ea-807b-32c6ac986a36.gif)

## 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 4.0.0.dev0 (Commit: c88697d5a) 
* Python 3.7.3 64-bit | Qt 5.9.6 | PyQt5 5.9.2 | Windows 10 



Discussion:

Resolving patch:
diff --git a/spyder/utils/qthelpers.py b/spyder/utils/qthelpers.py
--- a/spyder/utils/qthelpers.py
+++ b/spyder/utils/qthelpers.py
@@ -315,7 +315,13 @@ def create_action(parent, text, shortcut=None, icon=None, tip=None,
 
 def add_shortcut_to_tooltip(action, context, name):
     """Add the shortcut associated with a given action to its tooltip"""
-    action.setToolTip(action.toolTip() + ' (%s)' %
+    if not hasattr(action, '_tooltip_backup'):
+        # We store the original tooltip of the action without its associated
+        # shortcut so that we can update the tooltip properly if shortcuts
+        # are changed by the user over the course of the current session.
+        # See spyder-ide/spyder#10726.
+        action._tooltip_backup = action.toolTip()
+    action.setToolTip(action._tooltip_backup + ' (%s)' %
                       CONF.get_shortcut(context=context, name=name))
 
 


Test patch: