From 555eef258f23b79f8e25862479a76c6a12733aab Mon Sep 17 00:00:00 2001 From: Kevin Ji <1146876+kevinji@users.noreply.github.com> Date: Wed, 11 Dec 2024 13:21:13 -0800 Subject: [PATCH] Add new fields to TracebackException, fix lineno type These are derived from the TracebackException docs: https://docs.python.org/3/library/traceback.html#traceback.TracebackException and the source code: https://github.com/python/cpython/blob/8b3cccf3f9508572d85b0044519f2bd5715dacad/Lib/traceback.py#L989 --- stdlib/traceback.pyi | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/stdlib/traceback.pyi b/stdlib/traceback.pyi index e36081acfa03..414a7dd37e3e 100644 --- a/stdlib/traceback.pyi +++ b/stdlib/traceback.pyi @@ -118,12 +118,21 @@ class TracebackException: if sys.version_info >= (3, 11): exceptions: list[TracebackException] | None __suppress_context__: bool + if sys.version_info >= (3, 11): + __notes__: list[str] | None stack: StackSummary + + # These fields only exist for `SyntaxError`s, but there is no way to express that in the type system. filename: str - lineno: int + lineno: str + if sys.version_info >= (3, 10): + end_lineno: str | None text: str offset: int + if sys.version_info >= (3, 10): + end_offset: int | None msg: str + if sys.version_info >= (3, 13): @property def exc_type_str(self) -> str: ...