diff --git a/IPython/core/inputsplitter.py b/IPython/core/inputsplitter.py index 84aa0a7..0256278 100644 --- a/IPython/core/inputsplitter.py +++ b/IPython/core/inputsplitter.py @@ -386,7 +386,7 @@ class InputSplitter(object): finally: self.reset() - def push(self, lines): + def push(self, lines:str) -> bool: """Push one or more lines of input. This stores the given lines and returns a status code indicating @@ -408,6 +408,7 @@ class InputSplitter(object): this value is also stored as a private attribute (``_is_complete``), so it can be queried at any time. """ + assert isinstance(lines, str) self._store(lines) source = self.source @@ -677,7 +678,7 @@ class IPythonInputSplitter(InputSplitter): finally: self.reset() - def push(self, lines): + def push(self, lines:str) -> bool: """Push one or more lines of IPython input. This stores the given lines and returns a status code indicating @@ -700,9 +701,8 @@ class IPythonInputSplitter(InputSplitter): this value is also stored as a private attribute (_is_complete), so it can be queried at any time. """ - + assert isinstance(lines, str) # We must ensure all input is pure unicode - lines = cast_unicode(lines, self.encoding) # ''.splitlines() --> [], but we need to push the empty line to transformers lines_list = lines.splitlines() if not lines_list: diff --git a/IPython/utils/text.py b/IPython/utils/text.py index e844203..14405ed 100644 --- a/IPython/utils/text.py +++ b/IPython/utils/text.py @@ -538,7 +538,7 @@ class FullEvalFormatter(Formatter): """ # copied from Formatter._vformat with minor changes to allow eval # and replace the format_spec code with slicing - def vformat(self, format_string, args, kwargs): + def vformat(self, format_string:str, args, kwargs)->str: result = [] for literal_text, field_name, format_spec, conversion in \ self.parse(format_string): @@ -566,7 +566,7 @@ class FullEvalFormatter(Formatter): # format the object and append to the result result.append(self.format_field(obj, '')) - return ''.join(py3compat.cast_unicode(s) for s in result) + return ''.join(result) class DollarFormatter(FullEvalFormatter):