From b673ed904afe9a00c453db73deb0e8edfa3f69c0 Mon Sep 17 00:00:00 2001 From: Hasan Ramezani Date: Sun, 8 Aug 2021 19:41:01 +0200 Subject: [PATCH 1/5] Update filter attr type in stdlib._warnings.pyi --- stdlib/_warnings.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/_warnings.pyi b/stdlib/_warnings.pyi index b7023cea8fe3..705ce7ec5367 100644 --- a/stdlib/_warnings.pyi +++ b/stdlib/_warnings.pyi @@ -1,8 +1,8 @@ -from typing import Any, Tuple, Type, overload +from typing import Any, Optional, Tuple, Type, overload _defaultaction: str _onceregistry: dict[Any, Any] -filters: list[Tuple[Any, ...]] +filters: list[Tuple[str, Optional[str], Type[Warning], Optional[str], int]] @overload def warn(message: str, category: Type[Warning] | None = ..., stacklevel: int = ..., source: Any | None = ...) -> None: ... From 39cbeab6f23ad09301bbc9fb90becc33d17c304f Mon Sep 17 00:00:00 2001 From: Hasan Ramezani Date: Sun, 8 Aug 2021 19:41:28 +0200 Subject: [PATCH 2/5] Add filters to stdlib.warnings.pyi --- stdlib/warnings.pyi | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/stdlib/warnings.pyi b/stdlib/warnings.pyi index 514bea3a225d..e9e0a3d284ae 100644 --- a/stdlib/warnings.pyi +++ b/stdlib/warnings.pyi @@ -1,9 +1,11 @@ from types import ModuleType, TracebackType -from typing import Any, TextIO, Type, overload +from typing import Any, Optional, TextIO, Tuple, Type, overload from typing_extensions import Literal from _warnings import warn as warn, warn_explicit as warn_explicit +filters: list[Tuple[str, Optional[str], Type[Warning], Optional[str], int]] + def showwarning( message: Warning | str, category: Type[Warning], filename: str, lineno: int, file: TextIO | None = ..., line: str | None = ... ) -> None: ... From a8093c0e154ce9e2f69d8e1d252251f13ed17d81 Mon Sep 17 00:00:00 2001 From: Hasan Ramezani Date: Sun, 8 Aug 2021 19:45:18 +0200 Subject: [PATCH 3/5] Address comments. --- stdlib/_warnings.pyi | 4 ++-- stdlib/warnings.pyi | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/stdlib/_warnings.pyi b/stdlib/_warnings.pyi index 705ce7ec5367..fef73e69c626 100644 --- a/stdlib/_warnings.pyi +++ b/stdlib/_warnings.pyi @@ -1,8 +1,8 @@ -from typing import Any, Optional, Tuple, Type, overload +from typing import Any, Tuple, Type, overload _defaultaction: str _onceregistry: dict[Any, Any] -filters: list[Tuple[str, Optional[str], Type[Warning], Optional[str], int]] +filters: list[tuple[str, str | None, Type[Warning], str | None, int]] @overload def warn(message: str, category: Type[Warning] | None = ..., stacklevel: int = ..., source: Any | None = ...) -> None: ... diff --git a/stdlib/warnings.pyi b/stdlib/warnings.pyi index e9e0a3d284ae..b07051bc1584 100644 --- a/stdlib/warnings.pyi +++ b/stdlib/warnings.pyi @@ -1,10 +1,10 @@ from types import ModuleType, TracebackType -from typing import Any, Optional, TextIO, Tuple, Type, overload +from typing import Any, TextIO, Sequence, Type, overload from typing_extensions import Literal from _warnings import warn as warn, warn_explicit as warn_explicit -filters: list[Tuple[str, Optional[str], Type[Warning], Optional[str], int]] +filters: Sequence[tuple[str, str | None, Type[Warning], str | None, int]] def showwarning( message: Warning | str, category: Type[Warning], filename: str, lineno: int, file: TextIO | None = ..., line: str | None = ... From 847c02f82db5df8621129d617254f42a01cb513a Mon Sep 17 00:00:00 2001 From: Hasan Ramezani Date: Sun, 8 Aug 2021 19:47:30 +0200 Subject: [PATCH 4/5] Fix isort problem. --- stdlib/warnings.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/warnings.pyi b/stdlib/warnings.pyi index b07051bc1584..8071468ed866 100644 --- a/stdlib/warnings.pyi +++ b/stdlib/warnings.pyi @@ -1,5 +1,5 @@ from types import ModuleType, TracebackType -from typing import Any, TextIO, Sequence, Type, overload +from typing import Any, Sequence, TextIO, Type, overload from typing_extensions import Literal from _warnings import warn as warn, warn_explicit as warn_explicit From bc9e0b0d0521274abc429b273b2bc131c941c0aa Mon Sep 17 00:00:00 2001 From: Hasan Ramezani Date: Sun, 8 Aug 2021 20:05:26 +0200 Subject: [PATCH 5/5] Add comment for warnings.filters --- stdlib/warnings.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/warnings.pyi b/stdlib/warnings.pyi index 8071468ed866..62c41c871853 100644 --- a/stdlib/warnings.pyi +++ b/stdlib/warnings.pyi @@ -4,7 +4,7 @@ from typing_extensions import Literal from _warnings import warn as warn, warn_explicit as warn_explicit -filters: Sequence[tuple[str, str | None, Type[Warning], str | None, int]] +filters: Sequence[tuple[str, str | None, Type[Warning], str | None, int]] # undocumented, do not mutate def showwarning( message: Warning | str, category: Type[Warning], filename: str, lineno: int, file: TextIO | None = ..., line: str | None = ...