diff options
author | arcadia-devtools <arcadia-devtools@yandex-team.ru> | 2022-05-02 12:04:00 +0300 |
---|---|---|
committer | arcadia-devtools <arcadia-devtools@yandex-team.ru> | 2022-05-02 12:04:00 +0300 |
commit | 6d4102c808d949679abef976da125ce9add38a4b (patch) | |
tree | 6860eab8f8f96155f1a6bb7ef7e8574bb539c5a1 /contrib/python/ipython/py3/IPython/core/interactiveshell.py | |
parent | 3d696cd6bae90f6dec92155deaef46752f4e5275 (diff) | |
download | ydb-6d4102c808d949679abef976da125ce9add38a4b.tar.gz |
intermediate changes
ref:7c966abfc0f8dc17181b1cb81dbfec353e66ba5e
Diffstat (limited to 'contrib/python/ipython/py3/IPython/core/interactiveshell.py')
-rw-r--r-- | contrib/python/ipython/py3/IPython/core/interactiveshell.py | 52 |
1 files changed, 40 insertions, 12 deletions
diff --git a/contrib/python/ipython/py3/IPython/core/interactiveshell.py b/contrib/python/ipython/py3/IPython/core/interactiveshell.py index e222e991c0..8fd546b847 100644 --- a/contrib/python/ipython/py3/IPython/core/interactiveshell.py +++ b/contrib/python/ipython/py3/IPython/core/interactiveshell.py @@ -297,19 +297,29 @@ class ExecutionInfo(object): store_history = False silent = False shell_futures = True + cell_id = None - def __init__(self, raw_cell, store_history, silent, shell_futures): + def __init__(self, raw_cell, store_history, silent, shell_futures, cell_id): self.raw_cell = raw_cell self.store_history = store_history self.silent = silent self.shell_futures = shell_futures + self.cell_id = cell_id def __repr__(self): name = self.__class__.__qualname__ - raw_cell = ((self.raw_cell[:50] + '..') - if len(self.raw_cell) > 50 else self.raw_cell) - return '<%s object at %x, raw_cell="%s" store_history=%s silent=%s shell_futures=%s>' %\ - (name, id(self), raw_cell, self.store_history, self.silent, self.shell_futures) + raw_cell = ( + (self.raw_cell[:50] + "..") if len(self.raw_cell) > 50 else self.raw_cell + ) + return '<%s object at %x, raw_cell="%s" store_history=%s silent=%s shell_futures=%s cell_id=%s>' % ( + name, + id(self), + raw_cell, + self.store_history, + self.silent, + self.shell_futures, + self.cell_id, + ) class ExecutionResult(object): @@ -2928,7 +2938,14 @@ class InteractiveShell(SingletonConfigurable): self.showtraceback() warn('Unknown failure executing module: <%s>' % mod_name) - def run_cell(self, raw_cell, store_history=False, silent=False, shell_futures=True): + def run_cell( + self, + raw_cell, + store_history=False, + silent=False, + shell_futures=True, + cell_id=None, + ): """Run a complete IPython cell. Parameters @@ -2955,14 +2972,22 @@ class InteractiveShell(SingletonConfigurable): result = None try: result = self._run_cell( - raw_cell, store_history, silent, shell_futures) + raw_cell, store_history, silent, shell_futures, cell_id + ) finally: self.events.trigger('post_execute') if not silent: self.events.trigger('post_run_cell', result) return result - def _run_cell(self, raw_cell:str, store_history:bool, silent:bool, shell_futures:bool): + def _run_cell( + self, + raw_cell: str, + store_history: bool, + silent: bool, + shell_futures: bool, + cell_id: str, + ) -> ExecutionResult: """Internal method to run a complete IPython cell.""" # we need to avoid calling self.transform_cell multiple time on the same thing @@ -2982,6 +3007,7 @@ class InteractiveShell(SingletonConfigurable): shell_futures=shell_futures, transformed_cell=transformed_cell, preprocessing_exc_tuple=preprocessing_exc_tuple, + cell_id=cell_id, ) # run_cell_async is async, but may not actually need an eventloop. @@ -3002,7 +3028,9 @@ class InteractiveShell(SingletonConfigurable): try: return runner(coro) except BaseException as e: - info = ExecutionInfo(raw_cell, store_history, silent, shell_futures) + info = ExecutionInfo( + raw_cell, store_history, silent, shell_futures, cell_id + ) result = ExecutionResult(info) result.error_in_exec = e self.showtraceback(running_compiled_code=True) @@ -3060,7 +3088,8 @@ class InteractiveShell(SingletonConfigurable): shell_futures=True, *, transformed_cell: Optional[str] = None, - preprocessing_exc_tuple: Optional[Any] = None + preprocessing_exc_tuple: Optional[Any] = None, + cell_id=None, ) -> ExecutionResult: """Run a complete IPython cell asynchronously. @@ -3091,8 +3120,7 @@ class InteractiveShell(SingletonConfigurable): .. versionadded:: 7.0 """ - info = ExecutionInfo( - raw_cell, store_history, silent, shell_futures) + info = ExecutionInfo(raw_cell, store_history, silent, shell_futures, cell_id) result = ExecutionResult(info) if (not raw_cell) or raw_cell.isspace(): |