Use string literals for typing warnings actions (#6192)

This commit is contained in:
Bas van Beek
2021-10-23 13:44:05 +02:00
committed by GitHub
parent b3f29b619b
commit e4fa30e840

View File

@@ -4,6 +4,8 @@ from typing_extensions import Literal
from _warnings import warn as warn, warn_explicit as warn_explicit
_ActionKind = Literal["default", "error", "ignore", "always", "module", "once"]
filters: Sequence[tuple[str, str | None, Type[Warning], str | None, int]] # undocumented, do not mutate
def showwarning(
@@ -11,9 +13,14 @@ def showwarning(
) -> None: ...
def formatwarning(message: Warning | str, category: Type[Warning], filename: str, lineno: int, line: str | None = ...) -> str: ...
def filterwarnings(
action: str, message: str = ..., category: Type[Warning] = ..., module: str = ..., lineno: int = ..., append: bool = ...
action: _ActionKind,
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 simplefilter(action: _ActionKind, category: Type[Warning] = ..., lineno: int = ..., append: bool = ...) -> None: ...
def resetwarnings() -> None: ...
class _OptionError(Exception): ...