Skip to content

Commit 46b883c

Browse files
warnings: New arguments to catch_warnings()
python/cpython#91435
1 parent 3a98e8b commit 46b883c

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

stdlib/warnings.pyi

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,20 @@ class WarningMessage:
5656
) -> None: ...
5757

5858
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: ...
59+
if sys.version_info >= (3, 11):
60+
@overload
61+
def __new__(cls, *, record: Literal[False] = ..., module: ModuleType | None = ..., action: _ActionKind | None = ..., category: type[Warning] = ..., lineno: int = ..., append: bool = ...) -> _catch_warnings_without_records: ...
62+
@overload
63+
def __new__(cls, *, record: Literal[True], module: ModuleType | None = ..., action: _ActionKind | None = ..., category: type[Warning] = ..., lineno: int = ..., append: bool = ...) -> _catch_warnings_with_records: ...
64+
@overload
65+
def __new__(cls, *, record: bool, module: ModuleType | None = ..., action: _ActionKind | None = ..., category: type[Warning] = ..., lineno: int = ..., append: bool = ...) -> catch_warnings: ...
66+
else:
67+
@overload
68+
def __new__(cls, *, record: Literal[False] = ..., module: ModuleType | None = ...) -> _catch_warnings_without_records: ...
69+
@overload
70+
def __new__(cls, *, record: Literal[True], module: ModuleType | None = ...) -> _catch_warnings_with_records: ...
71+
@overload
72+
def __new__(cls, *, record: bool, module: ModuleType | None = ...) -> catch_warnings: ...
6573
def __enter__(self) -> list[WarningMessage] | None: ...
6674
def __exit__(
6775
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None

0 commit comments

Comments
 (0)