Skip to content

Commit 71c74fe

Browse files
Fixed several typing issues.
1 parent 513b9f4 commit 71c74fe

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

ptpython/python_input.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ def __init__(
388388
# Create an app if requested. If not, the global get_app() is returned
389389
# for self.app via property getter.
390390
if create_app:
391-
self._app = self._create_application(input, output)
391+
self._app: Optional[Application] = self._create_application(input, output)
392392
# Setting vi_mode will not work unless the prompt_toolkit
393393
# application has been created.
394394
if vi_mode:

ptpython/repl.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)