Skip to content

Commit 8ad4f1b

Browse files
authored
Add new fields to TracebackException, fix cause/context/lineno types (#13231)
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
1 parent 8235252 commit 8ad4f1b

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

stdlib/traceback.pyi

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,17 +113,26 @@ if sys.version_info >= (3, 11):
113113
def emit(self, text_gen: str | Iterable[str], margin_char: str | None = None) -> Generator[str, None, None]: ...
114114

115115
class TracebackException:
116-
__cause__: TracebackException
117-
__context__: TracebackException
116+
__cause__: TracebackException | None
117+
__context__: TracebackException | None
118118
if sys.version_info >= (3, 11):
119119
exceptions: list[TracebackException] | None
120120
__suppress_context__: bool
121+
if sys.version_info >= (3, 11):
122+
__notes__: list[str] | None
121123
stack: StackSummary
124+
125+
# These fields only exist for `SyntaxError`s, but there is no way to express that in the type system.
122126
filename: str
123-
lineno: int
127+
lineno: str | None
128+
if sys.version_info >= (3, 10):
129+
end_lineno: str | None
124130
text: str
125131
offset: int
132+
if sys.version_info >= (3, 10):
133+
end_offset: int | None
126134
msg: str
135+
127136
if sys.version_info >= (3, 13):
128137
@property
129138
def exc_type_str(self) -> str: ...

0 commit comments

Comments
 (0)