From 5ef103feb59fa86c035ccb15c05de0727a7666a8 2024-02-08 09:43:24 From: Matthias Bussonnier Date: 2024-02-08 09:43:24 Subject: [PATCH] more types --- diff --git a/IPython/core/inputsplitter.py b/IPython/core/inputsplitter.py index 33ed563..02e44d0 100644 --- a/IPython/core/inputsplitter.py +++ b/IPython/core/inputsplitter.py @@ -32,6 +32,7 @@ import tokenize import warnings from typing import List, Tuple, Union, Optional +from typing_extensions import Self from types import CodeType from IPython.core.inputtransformer import (leading_indent, @@ -637,9 +638,9 @@ class IPythonInputSplitter(InputSplitter): # Nothing that calls reset() expects to handle transformer # errors pass - - def flush_transformers(self): - def _flush(transform, outs): + + def flush_transformers(self: Self): + def _flush(transform, outs: List[str]): """yield transformed lines always strings, never None diff --git a/IPython/core/interactiveshell.py b/IPython/core/interactiveshell.py index 415f088..904f7b2 100644 --- a/IPython/core/interactiveshell.py +++ b/IPython/core/interactiveshell.py @@ -281,13 +281,14 @@ class ExecutionInfo(object): ) -class ExecutionResult(object): +class ExecutionResult: """The result of a call to :meth:`InteractiveShell.run_cell` Stores information about what took place. """ - execution_count = None - error_before_exec = None + + execution_count: Optional[int] = None + error_before_exec: Optional[bool] = None error_in_exec: Optional[BaseException] = None info = None result = None @@ -477,7 +478,8 @@ class InteractiveShell(SingletonConfigurable): def input_transformers_cleanup(self): return self.input_transformer_manager.cleanup_transforms - input_transformers_post = List([], + input_transformers_post: List = List( + [], help="A list of string input transformers, to be applied after IPython's " "own input transformations." ) @@ -3340,6 +3342,7 @@ class InteractiveShell(SingletonConfigurable): self.displayhook.exec_result = None if store_history: + assert self.history_manager is not None # Write output to the database. Does nothing unless # history output logging is enabled. self.history_manager.store_output(self.execution_count)