Files
typeshed/stdlib/2and3/warnings.pyi
Jelle Zijlstra d215f502c6 Improve warnings stubs (#3501)
* merge 2and3 for _warnings

* move warn and warn_explicit into _warnings
2019-12-03 14:33:37 +01:00

42 lines
1.7 KiB
Python

from typing import List, NamedTuple, Optional, overload, TextIO, Type
from types import ModuleType, TracebackType
from typing_extensions import Literal
from _warnings import warn as warn, warn_explicit as warn_explicit
def showwarning(
message: str, category: Type[Warning], filename: str, lineno: int, file: Optional[TextIO] = ..., line: Optional[str] = ...
) -> None: ...
def formatwarning(message: str, category: Type[Warning], filename: str, lineno: int, line: Optional[str] = ...) -> str: ...
def filterwarnings(
action: str, message: str = ..., category: Type[Warning] = ..., module: str = ..., lineno: int = ..., append: bool = ...
) -> None: ...
def simplefilter(action: str, category: Type[Warning] = ..., lineno: int = ..., append: bool = ...) -> None: ...
def resetwarnings() -> None: ...
class _Record(NamedTuple):
message: str
category: Type[Warning]
filename: str
lineno: int
file: Optional[TextIO]
line: Optional[str]
class catch_warnings:
@overload
def __new__(cls, *, record: Literal[False] = ..., module: Optional[ModuleType] = ...) -> _catch_warnings_without_records: ...
@overload
def __new__(cls, *, record: Literal[True], module: Optional[ModuleType] = ...) -> _catch_warnings_with_records: ...
@overload
def __new__(cls, *, record: bool, module: Optional[ModuleType] = ...) -> catch_warnings: ...
def __enter__(self) -> Optional[List[_Record]]: ...
def __exit__(
self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]
) -> None: ...
class _catch_warnings_without_records(catch_warnings):
def __enter__(self) -> None: ...
class _catch_warnings_with_records(catch_warnings):
def __enter__(self) -> List[_Record]: ...