@@ -2,6 +2,7 @@ import sys
2
2
from _typeshed import Self , SupportsWrite
3
3
from types import FrameType , TracebackType
4
4
from typing import IO , Any , Generator , Iterable , Iterator , Mapping , Optional , overload
5
+ from typing_extensions import Literal
5
6
6
7
_PT = tuple [str , int , str , Optional [str ]]
7
8
@@ -127,25 +128,53 @@ class TracebackException:
127
128
def format_exception_only (self ) -> Generator [str , None , None ]: ...
128
129
129
130
class FrameSummary (Iterable [Any ]):
131
+ if sys .version_info >= (3 , 11 ):
132
+ def __init__ (
133
+ self ,
134
+ filename : str ,
135
+ lineno : int | None ,
136
+ name : str ,
137
+ * ,
138
+ lookup_line : bool = ...,
139
+ locals : Mapping [str , str ] | None = ...,
140
+ line : str | None = ...,
141
+ end_lineno : int | None = ...,
142
+ colno : int | None = ...,
143
+ end_colno : int | None = ...,
144
+ ) -> None : ...
145
+ end_lineno : int | None
146
+ colno : int | None
147
+ end_colno : int | None
148
+ else :
149
+ def __init__ (
150
+ self ,
151
+ filename : str ,
152
+ lineno : int | None ,
153
+ name : str ,
154
+ * ,
155
+ lookup_line : bool = ...,
156
+ locals : Mapping [str , str ] | None = ...,
157
+ line : str | None = ...,
158
+ ) -> None : ...
130
159
filename : str
131
- lineno : int
160
+ lineno : int | None
132
161
name : str
133
- line : str
134
162
locals : dict [str , str ] | None
135
- def __init__ (
136
- self ,
137
- filename : str ,
138
- lineno : int ,
139
- name : str ,
140
- * ,
141
- lookup_line : bool = ...,
142
- locals : Mapping [str , str ] | None = ...,
143
- line : str | None = ...,
144
- ) -> None : ...
145
- # TODO: more precise typing for __getitem__ and __iter__,
146
- # for a namedtuple-like view on (filename, lineno, name, str).
163
+ @property
164
+ def line (self ) -> str | None : ...
165
+ @overload
166
+ def __getitem__ (self , i : Literal [0 ]) -> str : ...
167
+ @overload
168
+ def __getitem__ (self , i : Literal [1 ]) -> int : ...
169
+ @overload
170
+ def __getitem__ (self , i : Literal [2 ]) -> str : ...
171
+ @overload
172
+ def __getitem__ (self , i : Literal [3 ]) -> str | None : ...
173
+ @overload
147
174
def __getitem__ (self , i : int ) -> Any : ...
148
175
def __iter__ (self ) -> Iterator [Any ]: ...
176
+ if sys .version_info >= (3 , 8 ):
177
+ def __len__ (self ) -> Literal [4 ]: ...
149
178
150
179
class StackSummary (list [FrameSummary ]):
151
180
@classmethod
0 commit comments