massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-pyright / node_modules / pyright / dist / typeshed-fallback / stdlib / traceback.pyi
1 import sys
2 from _typeshed import SupportsWrite
3 from types import FrameType, TracebackType
4 from typing import IO, Any, Generator, Iterable, Iterator, List, Mapping, Optional, Tuple, Type
5
6 _PT = Tuple[str, int, str, Optional[str]]
7
8 def print_tb(tb: TracebackType | None, limit: int | None = ..., file: IO[str] | None = ...) -> None: ...
9
10 if sys.version_info >= (3, 10):
11     def print_exception(
12         __exc: Type[BaseException] | None,
13         value: BaseException | None = ...,
14         tb: TracebackType | None = ...,
15         limit: int | None = ...,
16         file: IO[str] | None = ...,
17         chain: bool = ...,
18     ) -> None: ...
19
20 else:
21     def print_exception(
22         etype: Type[BaseException] | None,
23         value: BaseException | None,
24         tb: TracebackType | None,
25         limit: int | None = ...,
26         file: IO[str] | None = ...,
27         chain: bool = ...,
28     ) -> None: ...
29
30 def print_exc(limit: int | None = ..., file: IO[str] | None = ..., chain: bool = ...) -> None: ...
31 def print_last(limit: int | None = ..., file: IO[str] | None = ..., chain: bool = ...) -> None: ...
32 def print_stack(f: FrameType | None = ..., limit: int | None = ..., file: IO[str] | None = ...) -> None: ...
33 def extract_tb(tb: TracebackType | None, limit: int | None = ...) -> StackSummary: ...
34 def extract_stack(f: FrameType | None = ..., limit: int | None = ...) -> StackSummary: ...
35 def format_list(extracted_list: list[FrameSummary]) -> list[str]: ...
36
37 # undocumented
38 def print_list(extracted_list: list[FrameSummary], file: SupportsWrite[str] | None = ...) -> None: ...
39
40 if sys.version_info >= (3, 10):
41     def format_exception_only(__exc: Type[BaseException] | None, value: BaseException | None = ...) -> list[str]: ...
42
43 else:
44     def format_exception_only(etype: Type[BaseException] | None, value: BaseException | None) -> list[str]: ...
45
46 if sys.version_info >= (3, 10):
47     def format_exception(
48         __exc: Type[BaseException] | None,
49         value: BaseException | None = ...,
50         tb: TracebackType | None = ...,
51         limit: int | None = ...,
52         chain: bool = ...,
53     ) -> list[str]: ...
54
55 else:
56     def format_exception(
57         etype: Type[BaseException] | None,
58         value: BaseException | None,
59         tb: TracebackType | None,
60         limit: int | None = ...,
61         chain: bool = ...,
62     ) -> list[str]: ...
63
64 def format_exc(limit: int | None = ..., chain: bool = ...) -> str: ...
65 def format_tb(tb: TracebackType | None, limit: int | None = ...) -> list[str]: ...
66 def format_stack(f: FrameType | None = ..., limit: int | None = ...) -> list[str]: ...
67 def clear_frames(tb: TracebackType) -> None: ...
68 def walk_stack(f: FrameType | None) -> Iterator[tuple[FrameType, int]]: ...
69 def walk_tb(tb: TracebackType | None) -> Iterator[tuple[FrameType, int]]: ...
70
71 class TracebackException:
72     __cause__: TracebackException
73     __context__: TracebackException
74     __suppress_context__: bool
75     stack: StackSummary
76     exc_type: Type[BaseException]
77     filename: str
78     lineno: int
79     text: str
80     offset: int
81     msg: str
82     if sys.version_info >= (3, 10):
83         def __init__(
84             self,
85             exc_type: Type[BaseException],
86             exc_value: BaseException,
87             exc_traceback: TracebackType,
88             *,
89             limit: int | None = ...,
90             lookup_lines: bool = ...,
91             capture_locals: bool = ...,
92             compact: bool = ...,
93             _seen: set[int] | None = ...,
94         ) -> None: ...
95         @classmethod
96         def from_exception(
97             cls,
98             exc: BaseException,
99             *,
100             limit: int | None = ...,
101             lookup_lines: bool = ...,
102             capture_locals: bool = ...,
103             compact: bool = ...,
104         ) -> TracebackException: ...
105     else:
106         def __init__(
107             self,
108             exc_type: Type[BaseException],
109             exc_value: BaseException,
110             exc_traceback: TracebackType,
111             *,
112             limit: int | None = ...,
113             lookup_lines: bool = ...,
114             capture_locals: bool = ...,
115             _seen: set[int] | None = ...,
116         ) -> None: ...
117         @classmethod
118         def from_exception(
119             cls, exc: BaseException, *, limit: int | None = ..., lookup_lines: bool = ..., capture_locals: bool = ...
120         ) -> TracebackException: ...
121     def format(self, *, chain: bool = ...) -> Generator[str, None, None]: ...
122     def format_exception_only(self) -> Generator[str, None, None]: ...
123
124 class FrameSummary(Iterable[Any]):
125     filename: str
126     lineno: int
127     name: str
128     line: str
129     locals: dict[str, str] | None
130     def __init__(
131         self,
132         filename: str,
133         lineno: int,
134         name: str,
135         *,
136         lookup_line: bool = ...,
137         locals: Mapping[str, str] | None = ...,
138         line: str | None = ...,
139     ) -> None: ...
140     # TODO: more precise typing for __getitem__ and __iter__,
141     # for a namedtuple-like view on (filename, lineno, name, str).
142     def __getitem__(self, i: int) -> Any: ...
143     def __iter__(self) -> Iterator[Any]: ...
144
145 class StackSummary(List[FrameSummary]):
146     @classmethod
147     def extract(
148         cls,
149         frame_gen: Iterable[tuple[FrameType, int]],
150         *,
151         limit: int | None = ...,
152         lookup_lines: bool = ...,
153         capture_locals: bool = ...,
154     ) -> StackSummary: ...
155     @classmethod
156     def from_list(cls, a_list: list[_PT]) -> StackSummary: ...
157     def format(self) -> list[str]: ...