From 2ffee9df1bb2edb17802689bc3aa13d2377ed496 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Mas=C5=82owski?= Date: Fri, 14 Apr 2017 16:40:27 +0200 Subject: [PATCH] Require warning categories to be subclasses of Warning (#343) CPython _warnings module implementation accepts Warning subclasses and None, but not any subclass of BaseException specified in the stub. The stub for warnings is correct. --- stdlib/2/_warnings.pyi | 6 +++--- stdlib/3/_warnings.pyi | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/stdlib/2/_warnings.pyi b/stdlib/2/_warnings.pyi index 4f54529db..63fd9d486 100644 --- a/stdlib/2/_warnings.pyi +++ b/stdlib/2/_warnings.pyi @@ -1,11 +1,11 @@ -from typing import Any, List +from typing import Any, List, Optional, Type default_action = ... # type: str filters = ... # type: List[tuple] once_registry = ... # type: dict -def warn(message: Warning, category: type = ..., stacklevel: int = ...) -> None: ... -def warn_explicit(message: Warning, category: type, +def warn(message: Warning, category: Optional[Type[Warning]] = ..., stacklevel: int = ...) -> None: ... +def warn_explicit(message: Warning, category: Optional[Type[Warning]], filename: str, lineno: int, module: Any = ..., registry: dict = ..., module_globals: dict = ...) -> None: ... diff --git a/stdlib/3/_warnings.pyi b/stdlib/3/_warnings.pyi index b1f0431d3..4d890e51c 100644 --- a/stdlib/3/_warnings.pyi +++ b/stdlib/3/_warnings.pyi @@ -1,11 +1,11 @@ -from typing import Any, List +from typing import Any, List, Optional, Type _defaultaction = ... # type: str _onceregistry = ... # type: dict filters = ... # type: List[tuple] -def warn(message: Warning, category: type = ..., stacklevel: int = ...) -> None: ... -def warn_explicit(message: Warning, category: type, +def warn(message: Warning, category: Optional[Type[Warning]] = ..., stacklevel: int = ...) -> None: ... +def warn_explicit(message: Warning, category: Optional[Type[Warning]], filename: str, lineno: int, module: Any = ..., registry: dict = ..., module_globals: dict = ...) -> None: ...