#13634 PR: Skip error when getting values (IPython console)

Open Quentin Peter impact27
Coverage Reach
plugins/editor/widgets/codeeditor.py plugins/editor/widgets/editor.py plugins/editor/widgets/base.py plugins/editor/widgets/completion.py plugins/editor/widgets/recover.py plugins/editor/widgets/status.py plugins/editor/widgets/autosaveerror.py plugins/editor/widgets/__init__.py plugins/editor/plugin.py plugins/editor/extensions/snippets.py plugins/editor/extensions/docstring.py plugins/editor/extensions/closebrackets.py plugins/editor/extensions/closequotes.py plugins/editor/extensions/manager.py plugins/editor/extensions/__init__.py plugins/editor/utils/editor.py plugins/editor/utils/autosave.py plugins/editor/utils/switcher.py plugins/editor/utils/folding.py plugins/editor/utils/debugger.py plugins/editor/utils/decoration.py plugins/editor/utils/kill_ring.py plugins/editor/utils/bookmarks.py plugins/editor/utils/findtasks.py plugins/editor/utils/languages.py plugins/editor/utils/__init__.py plugins/editor/panels/codefolding.py plugins/editor/panels/manager.py plugins/editor/panels/scrollflag.py plugins/editor/panels/classfunctiondropdown.py plugins/editor/panels/linenumber.py plugins/editor/panels/debugger.py plugins/editor/panels/indentationguides.py plugins/editor/panels/edgeline.py plugins/editor/panels/__init__.py plugins/editor/confpage.py plugins/editor/api/decoration.py plugins/editor/api/folding.py plugins/editor/api/__init__.py plugins/editor/__init__.py plugins/variableexplorer/widgets/collectionseditor.py plugins/variableexplorer/widgets/dataframeeditor.py plugins/variableexplorer/widgets/objectexplorer/tree_model.py plugins/variableexplorer/widgets/objectexplorer/objectexplorer.py plugins/variableexplorer/widgets/objectexplorer/attribute_model.py plugins/variableexplorer/widgets/objectexplorer/toggle_column_mixin.py plugins/variableexplorer/widgets/objectexplorer/tree_item.py plugins/variableexplorer/widgets/objectexplorer/__init__.py plugins/variableexplorer/widgets/objectexplorer/utils.py plugins/variableexplorer/widgets/arrayeditor.py plugins/variableexplorer/widgets/importwizard.py plugins/variableexplorer/widgets/collectionsdelegate.py plugins/variableexplorer/widgets/namespacebrowser.py plugins/variableexplorer/widgets/objecteditor.py plugins/variableexplorer/widgets/texteditor.py plugins/variableexplorer/widgets/basedialog.py plugins/variableexplorer/widgets/__init__.py plugins/variableexplorer/plugin.py plugins/variableexplorer/confpage.py plugins/variableexplorer/__init__.py plugins/completion/languageserver/confpage.py plugins/completion/languageserver/plugin.py plugins/completion/languageserver/client.py plugins/completion/languageserver/providers/document.py plugins/completion/languageserver/providers/workspace.py plugins/completion/languageserver/providers/utils.py plugins/completion/languageserver/providers/window.py plugins/completion/languageserver/providers/client.py plugins/completion/languageserver/providers/__init__.py plugins/completion/languageserver/transport/common/consumer.py plugins/completion/languageserver/transport/common/producer.py plugins/completion/languageserver/transport/stdio/producer.py plugins/completion/languageserver/transport/stdio/consumer.py plugins/completion/languageserver/transport/tcp/producer.py plugins/completion/languageserver/transport/tcp/consumer.py plugins/completion/languageserver/transport/main.py plugins/completion/languageserver/transport/__init__.py plugins/completion/languageserver/__init__.py plugins/completion/languageserver/widgets/status.py plugins/completion/languageserver/widgets/__init__.py plugins/completion/languageserver/decorators.py plugins/completion/kite/widgets/install.py plugins/completion/kite/widgets/calltoaction.py plugins/completion/kite/widgets/status.py plugins/completion/kite/widgets/__init__.py plugins/completion/kite/utils/install.py plugins/completion/kite/utils/status.py plugins/completion/kite/utils/__init__.py plugins/completion/kite/providers/document.py plugins/completion/kite/providers/__init__.py plugins/completion/kite/plugin.py plugins/completion/kite/client.py plugins/completion/kite/decorators.py plugins/completion/kite/parsing/__init__.py plugins/completion/kite/__init__.py plugins/completion/kite/bloomfilter/__init__.py plugins/completion/plugin.py plugins/completion/fallback/utils.py plugins/completion/fallback/actor.py plugins/completion/fallback/plugin.py plugins/completion/decorators.py plugins/completion/__init__.py plugins/ipythonconsole/widgets/client.py plugins/ipythonconsole/widgets/shell.py plugins/ipythonconsole/widgets/debugging.py plugins/ipythonconsole/widgets/kernelconnect.py plugins/ipythonconsole/widgets/namespacebrowser.py plugins/ipythonconsole/widgets/help.py plugins/ipythonconsole/widgets/control.py plugins/ipythonconsole/widgets/figurebrowser.py plugins/ipythonconsole/widgets/__init__.py plugins/ipythonconsole/plugin.py plugins/ipythonconsole/utils/style.py plugins/ipythonconsole/utils/kernelspec.py plugins/ipythonconsole/utils/ssh.py plugins/ipythonconsole/utils/manager.py plugins/ipythonconsole/utils/__init__.py plugins/ipythonconsole/confpage.py plugins/ipythonconsole/comms/kernelcomm.py plugins/ipythonconsole/comms/__init__.py plugins/ipythonconsole/__init__.py plugins/explorer/widgets/explorer.py plugins/explorer/widgets/fileassociations.py plugins/explorer/widgets/__init__.py plugins/explorer/plugin.py plugins/explorer/confpage.py plugins/explorer/__init__.py plugins/console/widgets/shell.py plugins/console/widgets/internalshell.py plugins/console/widgets/console.py plugins/console/widgets/__init__.py plugins/console/utils/interpreter.py plugins/console/utils/ansihandler.py plugins/console/utils/__init__.py plugins/console/plugin.py plugins/console/__init__.py plugins/findinfiles/widgets.py plugins/findinfiles/plugin.py plugins/findinfiles/__init__.py plugins/outlineexplorer/widgets.py plugins/outlineexplorer/api.py plugins/outlineexplorer/plugin.py plugins/outlineexplorer/editor.py plugins/outlineexplorer/languages.py plugins/outlineexplorer/__init__.py plugins/projects/plugin.py plugins/projects/widgets/explorer.py plugins/projects/widgets/projectdialog.py plugins/projects/widgets/__init__.py plugins/projects/utils/watcher.py plugins/projects/utils/config.py plugins/projects/utils/__init__.py plugins/projects/projecttypes/__init__.py plugins/projects/projecttypes/python.py plugins/projects/__init__.py plugins/projects/confpage.py plugins/help/plugin.py plugins/help/utils/sphinxify.py plugins/help/utils/sphinxthread.py plugins/help/utils/conf.py plugins/help/utils/__init__.py plugins/help/widgets.py plugins/help/confpage.py plugins/help/__init__.py plugins/onlinehelp/pydoc_patch.py plugins/onlinehelp/widgets.py plugins/onlinehelp/plugin.py plugins/onlinehelp/__init__.py plugins/plots/widgets/figurebrowser.py plugins/plots/plugin.py plugins/plots/__init__.py plugins/profiler/widgets/profilergui.py plugins/profiler/plugin.py plugins/profiler/confpage.py plugins/profiler/__init__.py plugins/pylint/widgets/pylintgui.py plugins/pylint/plugin.py plugins/pylint/confpage.py plugins/pylint/utils.py plugins/pylint/__init__.py plugins/history/plugin.py plugins/history/widgets.py plugins/history/confpage.py plugins/history/__init__.py plugins/base.py plugins/breakpoints/widgets/breakpointsgui.py plugins/breakpoints/plugin.py plugins/breakpoints/__init__.py plugins/workingdirectory/plugin.py plugins/workingdirectory/confpage.py plugins/workingdirectory/__init__.py plugins/io_hdf5/plugin.py plugins/io_hdf5/__init__.py plugins/io_dcm/plugin.py plugins/io_dcm/__init__.py plugins/__init__.py widgets/mixins.py widgets/switcher.py widgets/findreplace.py widgets/calltip.py widgets/tabs.py widgets/pathmanager.py widgets/arraybuilder.py widgets/browser.py widgets/helperwidgets.py widgets/comboboxes.py widgets/reporterror.py widgets/github/backend.py widgets/github/gh_login.py widgets/github/__init__.py widgets/status.py widgets/waitingspinner.py widgets/onecolumntree.py widgets/dock.py widgets/dependencies.py widgets/shortcutssummary.py widgets/colors.py widgets/about.py widgets/__init__.py utils/syntaxhighlighters.py utils/programs.py utils/snippets/nodes.py utils/snippets/parser.py utils/snippets/ast.py utils/snippets/lexer.py utils/qthelpers.py utils/introspection/old_fallback.py utils/introspection/rope_patch.py utils/introspection/module_completion.py utils/introspection/__init__.py utils/workers.py utils/encoding.py utils/misc.py utils/sourcecode.py utils/icon_manager.py utils/vcs.py utils/stringmatching.py utils/environ.py utils/switcher.py utils/debug.py utils/bsdsocket.py utils/conda.py utils/system.py utils/windows.py utils/fixtures.py utils/qstringhelpers.py utils/test.py utils/__init__.py app/mainwindow.py app/tour.py app/restart.py app/start.py app/utils.py app/cli_options.py app/__init__.py preferences/configdialog.py preferences/shortcuts.py preferences/runconfig.py preferences/appearance.py preferences/layoutdialog.py preferences/general.py preferences/maininterpreter.py preferences/__init__.py config/user.py config/base.py config/manager.py config/utils.py config/gui.py config/main.py config/fonts.py config/appearance.py config/lsp.py api/plugins.py api/panel.py api/editorextension.py api/completion.py api/preferences.py api/manager.py api/editor.py api/translations.py api/__init__.py py3compat.py dependencies.py workers/updates.py otherplugins.py requirements.py __init__.py pil_patch.py pyplot.py

No flags found

Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.

e.g., #unittest #integration

#production #enterprise

#frontend #backend

Learn more about Codecov Flags here.


@@ -115,11 +115,11 @@
Loading
115 115
                'pickle_protocol': pickle.HIGHEST_PROTOCOL}))
116 116
117 117
    def remote_call(self, interrupt=False, blocking=False, callback=None,
118 -
                    comm_id=None, timeout=None):
118 +
                    comm_id=None, timeout=None, display_error=False):
119 119
        """Get a handler for remote calls."""
120 120
        return super(KernelComm, self).remote_call(
121 121
            interrupt=interrupt, blocking=blocking, callback=callback,
122 -
            comm_id=comm_id, timeout=timeout)
122 +
            comm_id=comm_id, timeout=timeout, display_error=display_error)
123 123
124 124
    # ---- Private -----
125 125
    def on_incoming_call(self, call_dict):

@@ -90,35 +90,50 @@
Loading
90 90
        reason_big = _("The variable is too big to be retrieved")
91 91
        reason_not_picklable = _("The variable is not picklable")
92 92
        reason_dead = _("The kernel is dead")
93 +
        reason_other = _("An error occured, see the console.")
93 94
        msg = _("%s.<br><br>"
94 95
                "Note: Please don't report this problem on Github, "
95 96
                "there's nothing to do about it.")
96 97
        try:
97 98
            return self.call_kernel(
98 99
                interrupt=True,
99 100
                blocking=True,
101 +
                display_error=True,
100 102
                timeout=CALL_KERNEL_TIMEOUT).get_value(name)
101 103
        except TimeoutError:
102 104
            raise ValueError(msg % reason_big)
103 105
        except (PicklingError, UnpicklingError):
104 106
            raise ValueError(msg % reason_not_picklable)
105 107
        except RuntimeError:
106 108
            raise ValueError(msg % reason_dead)
109 +
        except KeyError:
110 +
            raise
111 +
        except Exception:
112 +
            raise ValueError(msg % reason_other)
107 113
108 114
    def set_value(self, name, value):
109 115
        """Set value for a variable"""
110 -
        self.call_kernel(interrupt=True, blocking=False
111 -
                         ).set_value(name, value)
116 +
        self.call_kernel(
117 +
            interrupt=True,
118 +
            blocking=False,
119 +
            display_error=True,
120 +
            ).set_value(name, value)
112 121
113 122
    def remove_value(self, name):
114 123
        """Remove a variable"""
115 -
        self.call_kernel(interrupt=True, blocking=False
116 -
                         ).remove_value(name)
124 +
        self.call_kernel(
125 +
            interrupt=True,
126 +
            blocking=False,
127 +
            display_error=True,
128 +
            ).remove_value(name)
117 129
118 130
    def copy_value(self, orig_name, new_name):
119 131
        """Copy a variable"""
120 -
        self.call_kernel(interrupt=True, blocking=False
121 -
                         ).copy_value(orig_name, new_name)
132 +
        self.call_kernel(
133 +
            interrupt=True,
134 +
            blocking=False,
135 +
            display_error=True,
136 +
            ).copy_value(orig_name, new_name)
122 137
123 138
    def load_data(self, filename, ext):
124 139
        """Load data from a file."""
@@ -135,6 +150,7 @@
Loading
135 150
            return self.call_kernel(
136 151
                interrupt=True,
137 152
                blocking=True,
153 +
                display_error=True,
138 154
                timeout=CALL_KERNEL_TIMEOUT).load_data(
139 155
                    filename, ext, overwrite=overwrite)
140 156
        except ImportError as msg:
@@ -156,6 +172,7 @@
Loading
156 172
            return self.call_kernel(
157 173
                interrupt=True,
158 174
                blocking=True,
175 +
                display_error=True,
159 176
                timeout=CALL_KERNEL_TIMEOUT).save_namespace(filename)
160 177
        except TimeoutError:
161 178
            msg = _("Data is too big to be saved")

@@ -161,7 +161,7 @@
Loading
161 161
        super(ShellWidget, self).will_close(externally_managed)
162 162
163 163
    def call_kernel(self, interrupt=False, blocking=False, callback=None,
164 -
                    timeout=None):
164 +
                    timeout=None, display_error=False):
165 165
        """
166 166
        Send message to Spyder kernel connected to this console.
167 167
@@ -181,12 +181,15 @@
Loading
181 181
            blocking call to the kernel. If None, a default timeout
182 182
            (defined in commbase.py, present in spyder-kernels) is
183 183
            used.
184 +
        display_error: bool
185 +
            If an error occurs, should it be printed to the console.
184 186
        """
185 187
        return self.spyder_kernel_comm.remote_call(
186 188
            interrupt=interrupt,
187 189
            blocking=blocking,
188 190
            callback=callback,
189 -
            timeout=timeout
191 +
            timeout=timeout,
192 +
            display_error=display_error
190 193
        )
191 194
192 195
    def set_kernel_client_and_manager(self, kernel_client, kernel_manager):

Learn more Showing 2 files with coverage changes found.

Changes in spyder/plugins/completion/languageserver/client.py
-6
+6
Loading file...
Changes in spyder/plugins/outlineexplorer/widgets.py
-2
+2
Loading file...
Files Coverage
spyder -0.02% 72.65%
Project Totals (289 files) 72.65%
Loading