Skip to content

Commit ac2b24c

Browse files
warnings: New arguments to catch_warnings() in 3.11 (#7685)
1 parent 125f9b4 commit ac2b24c

File tree

1 file changed

+43
-6
lines changed

1 file changed

+43
-6
lines changed

stdlib/warnings.pyi

+43-6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import sys
12
from _warnings import warn as warn, warn_explicit as warn_explicit
23
from collections.abc import Sequence
34
from types import ModuleType, TracebackType
@@ -56,12 +57,48 @@ class WarningMessage:
5657
) -> None: ...
5758

5859
class catch_warnings:
59-
@overload
60-
def __new__(cls, *, record: Literal[False] = ..., module: ModuleType | None = ...) -> _catch_warnings_without_records: ...
61-
@overload
62-
def __new__(cls, *, record: Literal[True], module: ModuleType | None = ...) -> _catch_warnings_with_records: ...
63-
@overload
64-
def __new__(cls, *, record: bool, module: ModuleType | None = ...) -> catch_warnings: ...
60+
if sys.version_info >= (3, 11):
61+
@overload
62+
def __new__(
63+
cls,
64+
*,
65+
record: Literal[False] = ...,
66+
module: ModuleType | None = ...,
67+
action: _ActionKind | None = ...,
68+
category: type[Warning] = ...,
69+
lineno: int = ...,
70+
append: bool = ...,
71+
) -> _catch_warnings_without_records: ...
72+
@overload
73+
def __new__(
74+
cls,
75+
*,
76+
record: Literal[True],
77+
module: ModuleType | None = ...,
78+
action: _ActionKind | None = ...,
79+
category: type[Warning] = ...,
80+
lineno: int = ...,
81+
append: bool = ...,
82+
) -> _catch_warnings_with_records: ...
83+
@overload
84+
def __new__(
85+
cls,
86+
*,
87+
record: bool,
88+
module: ModuleType | None = ...,
89+
action: _ActionKind | None = ...,
90+
category: type[Warning] = ...,
91+
lineno: int = ...,
92+
append: bool = ...,
93+
) -> catch_warnings: ...
94+
else:
95+
@overload
96+
def __new__(cls, *, record: Literal[False] = ..., module: ModuleType | None = ...) -> _catch_warnings_without_records: ...
97+
@overload
98+
def __new__(cls, *, record: Literal[True], module: ModuleType | None = ...) -> _catch_warnings_with_records: ...
99+
@overload
100+
def __new__(cls, *, record: bool, module: ModuleType | None = ...) -> catch_warnings: ...
101+
65102
def __enter__(self) -> list[WarningMessage] | None: ...
66103
def __exit__(
67104
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None

0 commit comments

Comments
 (0)