Repository: spyder-ide/spyder

Issue:
Check handling of str responses in Kite client signals
Sorry for taking so long to respond. I've included everything that I thought might be relevant. I think @metalogical has it right, however I it would be pretty difficult for me to convince the security guys at work to change anything. Would it be possible to change the error handling so it is able to continue after an error like this? Especially since I have explicitly disabled Kite and the software works fine if it encounters the error when already running. 

	2020-04-20 12:05:42,162 [DEBUG] [spyder.plugins.editor.plugin] -> Start completion server for C:\Users\[removed]\.spyder-py3\temp.py [Python]
	2020-04-20 12:05:42,162 [DEBUG] [spyder.plugins.editor.plugin] -> Python completion server is ready
	2020-04-20 12:05:42,164 [DEBUG] [spyder.plugins.editor.widgets.codeeditor] -> Completions services available for: C:\Users\[removed]\.spyder-py3\temp.py
	2020-04-20 12:05:42,164 [DEBUG] [spyder.plugins.editor.plugin] -> python completion server request: 'textDocument/didOpen'
	2020-04-20 12:05:42,165 [DEBUG] [spyder.plugins.completion.plugin] -> Completion plugin: Request 0 Got response from lsp
	2020-04-20 12:05:42,165 [DEBUG] [spyder.plugins.completion.plugin] -> Gather responses for textDocument/didOpen
	2020-04-20 12:05:42,165 [DEBUG] [spyder.plugins.completion.plugin] -> Completion plugin: Request 0 Got response from kite
	2020-04-20 12:05:42,166 [DEBUG] [spyder.plugins.editor.widgets.editor] -> Set focus to: C:\Users\[removed]\.spyder-py3\temp.py
	2020-04-20 12:05:42,166 [DEBUG] [spyder.plugins.completion.fallback.actor] -> Got request id 0: textDocument/didOpen for file C:\Users\[removed]\.spyder-py3\temp.py
	2020-04-20 12:05:42,167 [DEBUG] [spyder.plugins.editor.widgets.editor] -> Current changed: 0 - C:\Users\[removed]\.spyder-py3\temp.py
	2020-04-20 12:05:42,170 [DEBUG] [spyder.plugins.editor.widgets.editor] -> Added thread <spyder.plugins.editor.widgets.editor.AnalysisThread object at 0x0000019B03720A68> to queue
	2020-04-20 12:05:42,189 [INFO] [spyder.app.mainwindow] -> Launching code completion client for Python...
	2020-04-20 12:05:42,203 [DEBUG] [spyder.plugins.completion.kite.client] -> Starting Kite HTTP session...
	2020-04-20 12:05:42,208 [DEBUG] [urllib3.connectionpool] -> Starting new HTTP connection (1): [vpn server name].[company name].com:80
	2020-04-20 12:05:42,512 [DEBUG] [urllib3.connectionpool] -> http://[vpn server name].[company name].com:80 "GET http://127.0.0.1:46624/clientapi/languages HTTP/1.1" 200 7277
	Traceback (most recent call last):
	  File "C:\Progra~1\Anaconda3\lib\site-packages\spyder\app\mainwindow.py", line 3718, in main
		mainwindow = run_spyder(app, options, args)
	  File "C:\Progra~1\Anaconda3\lib\site-packages\spyder\app\mainwindow.py", line 3559, in run_spyder
		main.setup()
	  File "C:\Progra~1\Anaconda3\lib\site-packages\spyder\app\mainwindow.py", line 960, in setup
		self.completions.start()
	  File "C:\Progra~1\Anaconda3\lib\site-packages\spyder\plugins\completion\plugin.py", line 292, in start
		client_info['plugin'].start()
	  File "C:\Progra~1\Anaconda3\lib\site-packages\spyder\plugins\completion\kite\plugin.py", line 144, in start
		self.client.start()
	  File "C:\Progra~1\Anaconda3\lib\site-packages\spyder\plugins\completion\kite\client.py", line 62, in start
		self.sig_client_started.emit(self.languages)
	TypeError: KiteClient.sig_client_started[list].emit(): argument 1 has unexpected type 'str'

_Originally posted by @nsluhrs in https://github.com/spyder-ide/spyder/issues/12357#issuecomment-616665440_


Discussion:

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
@@ -79,7 +79,7 @@ def stop(self):
     def get_languages(self):
         verb, url = KITE_ENDPOINTS.LANGUAGES_ENDPOINT
         success, response = self.perform_http_request(verb, url)
-        if response is None:
+        if response is None or isinstance(response, TEXT_TYPES):
             response = ['python']
         return response
 
@@ -112,16 +112,12 @@ def get_status(self, filename):
             kite_status = status()
             self.sig_status_response_ready[str].emit(kite_status)
         elif isinstance(kite_status, TEXT_TYPES):
-            if not success_status:
-                status_str = status(extra_status=' with errors')
-                long_str = _("<code>{error}</code><br><br>"
-                             "Note: If you are using a VPN, "
-                             "please don't route requests to "
-                             "localhost/127.0.0.1 with it").format(
-                                 error=kite_status)
-            else:
-                status_str = status()
-                long_str = kite_status
+            status_str = status(extra_status=' with errors')
+            long_str = _("<code>{error}</code><br><br>"
+                         "Note: If you are using a VPN, "
+                         "please don't route requests to "
+                         "localhost/127.0.0.1 with it").format(
+                             error=kite_status)
             kite_status_dict = {
                 'status': status_str,
                 'short': status_str,


Test patch: