Skip to content

Improve traceback.FrameSummary #7210

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 43 additions & 14 deletions stdlib/traceback.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import sys
from _typeshed import Self, SupportsWrite
from types import FrameType, TracebackType
from typing import IO, Any, Generator, Iterable, Iterator, Mapping, Optional, overload
from typing_extensions import Literal

_PT = tuple[str, int, str, Optional[str]]

Expand Down Expand Up @@ -127,25 +128,53 @@ class TracebackException:
def format_exception_only(self) -> Generator[str, None, None]: ...

class FrameSummary(Iterable[Any]):
if sys.version_info >= (3, 11):
def __init__(
self,
filename: str,
lineno: int | None,
name: str,
*,
lookup_line: bool = ...,
locals: Mapping[str, str] | None = ...,
line: str | None = ...,
end_lineno: int | None = ...,
colno: int | None = ...,
end_colno: int | None = ...,
) -> None: ...
end_lineno: int | None
colno: int | None
end_colno: int | None
else:
def __init__(
self,
filename: str,
lineno: int | None,
name: str,
*,
lookup_line: bool = ...,
locals: Mapping[str, str] | None = ...,
line: str | None = ...,
) -> None: ...
filename: str
lineno: int
lineno: int | None
name: str
line: str
locals: dict[str, str] | None
def __init__(
self,
filename: str,
lineno: int,
name: str,
*,
lookup_line: bool = ...,
locals: Mapping[str, str] | None = ...,
line: str | None = ...,
) -> None: ...
# TODO: more precise typing for __getitem__ and __iter__,
# for a namedtuple-like view on (filename, lineno, name, str).
@property
def line(self) -> str | None: ...
@overload
def __getitem__(self, i: Literal[0]) -> str: ...
@overload
def __getitem__(self, i: Literal[1]) -> int: ...
@overload
def __getitem__(self, i: Literal[2]) -> str: ...
@overload
def __getitem__(self, i: Literal[3]) -> str | None: ...
@overload
def __getitem__(self, i: int) -> Any: ...
def __iter__(self) -> Iterator[Any]: ...
if sys.version_info >= (3, 8):
def __len__(self) -> Literal[4]: ...

class StackSummary(list[FrameSummary]):
@classmethod
Expand Down