From 3950543bce9dc2c0da8554e49bcaf587a7053c1f Mon Sep 17 00:00:00 2001 From: Shantanu <12621235+hauntsaninja@users.noreply.github.com> Date: Sun, 2 May 2021 18:54:47 -0700 Subject: [PATCH] traceback: update for py310 (#5316) I think technically you need to pass both of value and tb or neither, so let me know if you think it's worth all the overloads --- stdlib/traceback.pyi | 43 +++++++++++++++++++++++++++++++++++++------ 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/stdlib/traceback.pyi b/stdlib/traceback.pyi index 866354274..3c24ee21b 100644 --- a/stdlib/traceback.pyi +++ b/stdlib/traceback.pyi @@ -7,7 +7,17 @@ _PT = Tuple[str, int, str, Optional[str]] def print_tb(tb: Optional[TracebackType], limit: Optional[int] = ..., file: Optional[IO[str]] = ...) -> None: ... -if sys.version_info >= (3,): +if sys.version_info >= (3, 10): + def print_exception( + __exc: Optional[Type[BaseException]], + value: Optional[BaseException] = ..., + tb: Optional[TracebackType] = ..., + limit: Optional[int] = ..., + file: Optional[IO[str]] = ..., + chain: bool = ..., + ) -> None: ... + +elif sys.version_info >= (3,): def print_exception( etype: Optional[Type[BaseException]], value: Optional[BaseException], @@ -16,8 +26,6 @@ if sys.version_info >= (3,): file: Optional[IO[str]] = ..., chain: bool = ..., ) -> None: ... - def print_exc(limit: Optional[int] = ..., file: Optional[IO[str]] = ..., chain: bool = ...) -> None: ... - def print_last(limit: Optional[int] = ..., file: Optional[IO[str]] = ..., chain: bool = ...) -> None: ... else: def print_exception( @@ -27,6 +35,12 @@ else: limit: Optional[int] = ..., file: Optional[IO[str]] = ..., ) -> None: ... + +if sys.version_info >= (3,): + def print_exc(limit: Optional[int] = ..., file: Optional[IO[str]] = ..., chain: bool = ...) -> None: ... + def print_last(limit: Optional[int] = ..., file: Optional[IO[str]] = ..., chain: bool = ...) -> None: ... + +else: def print_exc(limit: Optional[int] = ..., file: Optional[IO[str]] = ...) -> None: ... def print_last(limit: Optional[int] = ..., file: Optional[IO[str]] = ...) -> None: ... @@ -44,9 +58,22 @@ else: def extract_stack(f: Optional[FrameType] = ..., limit: Optional[int] = ...) -> List[_PT]: ... def format_list(extracted_list: List[_PT]) -> List[str]: ... -def format_exception_only(etype: Optional[Type[BaseException]], value: Optional[BaseException]) -> List[str]: ... +if sys.version_info >= (3, 10): + def format_exception_only(__exc: Optional[Type[BaseException]], value: Optional[BaseException] = ...) -> List[str]: ... -if sys.version_info >= (3,): +else: + def format_exception_only(etype: Optional[Type[BaseException]], value: Optional[BaseException]) -> List[str]: ... + +if sys.version_info >= (3, 10): + def format_exception( + __exc: Optional[Type[BaseException]], + value: Optional[BaseException] = ..., + tb: Optional[TracebackType] = ..., + limit: Optional[int] = ..., + chain: bool = ..., + ) -> List[str]: ... + +elif sys.version_info >= (3,): def format_exception( etype: Optional[Type[BaseException]], value: Optional[BaseException], @@ -54,7 +81,6 @@ if sys.version_info >= (3,): limit: Optional[int] = ..., chain: bool = ..., ) -> List[str]: ... - def format_exc(limit: Optional[int] = ..., chain: bool = ...) -> str: ... else: def format_exception( @@ -63,6 +89,11 @@ else: tb: Optional[TracebackType], limit: Optional[int] = ..., ) -> List[str]: ... + +if sys.version_info >= (3,): + def format_exc(limit: Optional[int] = ..., chain: bool = ...) -> str: ... + +else: def format_exc(limit: Optional[int] = ...) -> str: ... def format_tb(tb: Optional[TracebackType], limit: Optional[int] = ...) -> List[str]: ...