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