@@ -294,7 +294,7 @@ def _compile_with_flags(self, code: str, mode: str):
294294 dont_inherit = True ,
295295 )
296296
297- def _format_result_output (self , result : object ) -> AnyFormattedText :
297+ def _format_result_output (self , result : object ) -> StyleAndTextTuples :
298298 """
299299 Format __repr__ for an `eval` result.
300300
@@ -312,7 +312,7 @@ def _format_result_output(self, result: object) -> AnyFormattedText:
312312 except BaseException as e :
313313 # Calling repr failed.
314314 self ._handle_exception (e )
315- return None
315+ return []
316316
317317 try :
318318 compile (result_repr , "" , "eval" )
@@ -502,7 +502,7 @@ def create_pager_prompt(self) -> PromptSession["PagerResult"]:
502502 """
503503 return create_pager_prompt (self ._current_style , self .title )
504504
505- def _format_exception_output (self , e : BaseException ) -> AnyFormattedText :
505+ def _format_exception_output (self , e : BaseException ) -> PygmentsTokens :
506506 # Instead of just calling ``traceback.format_exc``, we take the
507507 # traceback and skip the bottom calls of this framework.
508508 t , v , tb = sys .exc_info ()
@@ -531,15 +531,15 @@ def _format_exception_output(self, e: BaseException) -> AnyFormattedText:
531531 tokens = list (_lex_python_traceback (tb_str ))
532532 else :
533533 tokens = [(Token , tb_str )]
534- return tokens
534+ return PygmentsTokens ( tokens )
535535
536536 def _handle_exception (self , e : BaseException ) -> None :
537537 output = self .app .output
538538
539539 tokens = self ._format_exception_output (e )
540540
541541 print_formatted_text (
542- PygmentsTokens ( tokens ) ,
542+ tokens ,
543543 style = self ._current_style ,
544544 style_transformation = self .style_transformation ,
545545 include_default_pygments_style = False ,
0 commit comments