From bef71f71f8e37a164a84a6e0cbdd0dc1f9fbcec1 Mon Sep 17 00:00:00 2001 From: dalthviz Date: Mon, 19 Dec 2022 14:34:11 -0500 Subject: [PATCH 1/2] Prevent Python variable validation to get current word and position when doing completions --- spyder/widgets/mixins.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spyder/widgets/mixins.py b/spyder/widgets/mixins.py index ee968ec2295..5b537a0f623 100644 --- a/spyder/widgets/mixins.py +++ b/spyder/widgets/mixins.py @@ -1083,7 +1083,7 @@ def is_special_character(move): startpos = cursor.selectionStart() # Find a valid Python variable name - if valid_python_variable: + if valid_python_variable and not completion: match = re.findall(r'([^\d\W]\w*)', text, re.UNICODE) if not match: # This is assumed in several places of our codebase, From 1580420480b892cdf3c00184c636b3524167147b Mon Sep 17 00:00:00 2001 From: dalthviz Date: Tue, 20 Dec 2022 13:36:53 -0500 Subject: [PATCH 2/2] Editor: Remove Kite completion response test --- .../widgets/tests/test_introspection.py | 53 ------------------- 1 file changed, 53 deletions(-) diff --git a/spyder/plugins/editor/widgets/tests/test_introspection.py b/spyder/plugins/editor/widgets/tests/test_introspection.py index 099bec3af4e..2d8f184ecc4 100644 --- a/spyder/plugins/editor/widgets/tests/test_introspection.py +++ b/spyder/plugins/editor/widgets/tests/test_introspection.py @@ -23,10 +23,6 @@ # Local imports from spyder.config.base import running_in_ci, running_in_ci_with_conda from spyder.config.utils import is_anaconda -from spyder.plugins.completion.api import ( - CompletionRequestTypes, CompletionItemKind) -from spyder.plugins.completion.providers.kite.providers.document import ( - KITE_COMPLETION) from spyder.plugins.completion.providers.kite.utils.status import ( check_if_kite_installed, check_if_kite_running) from spyder.py3compat import PY2 @@ -1068,55 +1064,6 @@ def test_text_snippet_completions(completions_codeeditor, qtbot): code_editor.toggle_code_snippets(True) -@pytest.mark.slow -@pytest.mark.order(1) -@flaky(max_runs=5) -def test_kite_textEdit_completions(mock_completions_codeeditor, qtbot): - """Test textEdit completions such as those returned by the Kite provider. - - This mocks out the completions response, and does not test the Kite - provider directly. - """ - code_editor, mock_response = mock_completions_codeeditor - completion = code_editor.completion_widget - - code_editor.toggle_automatic_completions(False) - code_editor.toggle_code_snippets(False) - - # Set cursor to start - code_editor.go_to_line(1) - - qtbot.keyClicks(code_editor, 'my_dict.') - - # Complete my_dict. -> my_dict["dict-key"] - mock_response.side_effect = lambda lang, method, params: {'params': [{ - 'kind': CompletionItemKind.TEXT, - 'label': '["dict-key"]', - 'textEdit': { - 'newText': '["dict-key"]', - 'range': { - 'start': 7, - 'end': 8, - }, - }, - 'filterText': '', - 'sortText': '', - 'documentation': '', - 'provider': KITE_COMPLETION, - }]} if method == CompletionRequestTypes.DOCUMENT_COMPLETION else None - with qtbot.waitSignal(completion.sig_show_completions, - timeout=10000) as sig: - qtbot.keyPress(code_editor, Qt.Key_Tab, delay=300) - mock_response.side_effect = None - - assert '["dict-key"]' in [x['label'] for x in sig.args[0]] - qtbot.keyPress(code_editor, Qt.Key_Enter, delay=300) - assert code_editor.toPlainText() == 'my_dict["dict-key"]\n' - - code_editor.toggle_automatic_completions(True) - code_editor.toggle_code_snippets(True) - - @pytest.mark.slow @pytest.mark.order(1) @flaky(max_runs=5)