1 from _warnings import warn as warn, warn_explicit as warn_explicit
2 from types import ModuleType, TracebackType
3 from typing import Any, Sequence, TextIO, Type, overload
4 from typing_extensions import Literal
6 _ActionKind = Literal["default", "error", "ignore", "always", "module", "once"]
8 filters: Sequence[tuple[str, str | None, Type[Warning], str | None, int]] # undocumented, do not mutate
11 message: Warning | str, category: Type[Warning], filename: str, lineno: int, file: TextIO | None = ..., line: str | None = ...
13 def formatwarning(message: Warning | str, category: Type[Warning], filename: str, lineno: int, line: str | None = ...) -> str: ...
17 category: Type[Warning] = ...,
22 def simplefilter(action: _ActionKind, category: Type[Warning] = ..., lineno: int = ..., append: bool = ...) -> None: ...
23 def resetwarnings() -> None: ...
25 class _OptionError(Exception): ...
28 message: Warning | str
29 category: Type[Warning]
37 message: Warning | str,
38 category: Type[Warning],
41 file: TextIO | None = ...,
42 line: str | None = ...,
43 source: Any | None = ...,
48 def __new__(cls, *, record: Literal[False] = ..., module: ModuleType | None = ...) -> _catch_warnings_without_records: ...
50 def __new__(cls, *, record: Literal[True], module: ModuleType | None = ...) -> _catch_warnings_with_records: ...
52 def __new__(cls, *, record: bool, module: ModuleType | None = ...) -> catch_warnings: ...
53 def __enter__(self) -> list[WarningMessage] | None: ...
55 self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
58 class _catch_warnings_without_records(catch_warnings):
59 def __enter__(self) -> None: ...
61 class _catch_warnings_with_records(catch_warnings):
62 def __enter__(self) -> list[WarningMessage]: ...