|
| 1 | +import sys |
1 | 2 | from _warnings import warn as warn, warn_explicit as warn_explicit
|
2 | 3 | from collections.abc import Sequence
|
3 | 4 | from types import ModuleType, TracebackType
|
@@ -56,12 +57,48 @@ class WarningMessage:
|
56 | 57 | ) -> None: ...
|
57 | 58 |
|
58 | 59 | 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 | + |
65 | 102 | def __enter__(self) -> list[WarningMessage] | None: ...
|
66 | 103 | def __exit__(
|
67 | 104 | self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
|
|
0 commit comments