Format: application/octet-stream
1 import sys
2 from types import ModuleType, TracebackType
3 from typing import Any, List, Optional, TextIO, Type, Union, overload
4 from typing_extensions import Literal
5
6 from _warnings import warn as warn, warn_explicit as warn_explicit
7
8 def showwarning(
9 message: Union[Warning, str],
10 category: Type[Warning],
11 filename: str,
12 lineno: int,
13 file: Optional[TextIO] = ...,
14 line: Optional[str] = ...,
15 ) -> None: ...
16 def formatwarning(
17 message: Union[Warning, str], category: Type[Warning], filename: str, lineno: int, line: Optional[str] = ...
18 ) -> str: ...
19 def filterwarnings(
20 action: str, message: str = ..., category: Type[Warning] = ..., module: str = ..., lineno: int = ..., append: bool = ...
21 ) -> None: ...
22 def simplefilter(action: str, category: Type[Warning] = ..., lineno: int = ..., append: bool = ...) -> None: ...
23 def resetwarnings() -> None: ...
24
25 class _OptionError(Exception): ...
26
27 class WarningMessage:
28 message: Union[Warning, str]
29 category: Type[Warning]
30 filename: str
31 lineno: int
32 file: Optional[TextIO]
33 line: Optional[str]
34 if sys.version_info >= (3, 6):
35 source: Optional[Any]
36 def __init__(
37 self,
38 message: Union[Warning, str],
39 category: Type[Warning],
40 filename: str,
41 lineno: int,
42 file: Optional[TextIO] = ...,
43 line: Optional[str] = ...,
44 source: Optional[Any] = ...,
45 ) -> None: ...
46 else:
47 def __init__(
48 self,
49 message: Union[Warning, str],
50 category: Type[Warning],
51 filename: str,
52 lineno: int,
53 file: Optional[TextIO] = ...,
54 line: Optional[str] = ...,
55 ) -> None: ...
56
57 class catch_warnings:
58 @overload
59 def __new__(cls, *, record: Literal[False] = ..., module: Optional[ModuleType] = ...) -> _catch_warnings_without_records: ...
60 @overload
61 def __new__(cls, *, record: Literal[True], module: Optional[ModuleType] = ...) -> _catch_warnings_with_records: ...
62 @overload
63 def __new__(cls, *, record: bool, module: Optional[ModuleType] = ...) -> catch_warnings: ...
64 def __enter__(self) -> Optional[List[WarningMessage]]: ...
65 def __exit__(
66 self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]
67 ) -> None: ...
68
69 class _catch_warnings_without_records(catch_warnings):
70 def __enter__(self) -> None: ...
71
72 class _catch_warnings_with_records(catch_warnings):
73 def __enter__(self) -> List[WarningMessage]: ...
74