mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 20:54:28 +08:00
Add typestubs for the warnings module (#3543)
This commit is contained in:
committed by
Jelle Zijlstra
parent
0c563130fd
commit
c44a556fb0
@@ -1,4 +1,5 @@
|
||||
from typing import List, NamedTuple, Optional, overload, TextIO, Type
|
||||
import sys
|
||||
from typing import Any, List, NamedTuple, Optional, overload, TextIO, Type
|
||||
from types import ModuleType, TracebackType
|
||||
from typing_extensions import Literal
|
||||
|
||||
@@ -14,13 +15,20 @@ def filterwarnings(
|
||||
def simplefilter(action: str, category: Type[Warning] = ..., lineno: int = ..., append: bool = ...) -> None: ...
|
||||
def resetwarnings() -> None: ...
|
||||
|
||||
class _Record(NamedTuple):
|
||||
message: str
|
||||
class _OptionError(Exception): ...
|
||||
|
||||
class WarningMessage:
|
||||
message: Warning
|
||||
category: Type[Warning]
|
||||
filename: str
|
||||
lineno: int
|
||||
file: Optional[TextIO]
|
||||
line: Optional[str]
|
||||
filename: Any
|
||||
lineno: Any
|
||||
file: Optional[Any]
|
||||
line: Optional[Any]
|
||||
if sys.version_info >= (3, 6):
|
||||
source: Optional[Any]
|
||||
def __init__(self, message: Warning, category: Type[Warning], filename: Any, lineno: Any, file: Optional[Any] = ..., line: Optional[Any] = ..., source: Optional[Any] = ...) -> None: ...
|
||||
else:
|
||||
def __init__(self, message: Warning, category: Type[Warning], filename: Any, lineno: Any, file: Optional[Any] = ..., line: Optional[Any] = ...) -> None: ...
|
||||
|
||||
class catch_warnings:
|
||||
@overload
|
||||
@@ -29,7 +37,7 @@ class catch_warnings:
|
||||
def __new__(cls, *, record: Literal[True], module: Optional[ModuleType] = ...) -> _catch_warnings_with_records: ...
|
||||
@overload
|
||||
def __new__(cls, *, record: bool, module: Optional[ModuleType] = ...) -> catch_warnings: ...
|
||||
def __enter__(self) -> Optional[List[_Record]]: ...
|
||||
def __enter__(self) -> Optional[List[WarningMessage]]: ...
|
||||
def __exit__(
|
||||
self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]
|
||||
) -> None: ...
|
||||
@@ -38,4 +46,4 @@ class _catch_warnings_without_records(catch_warnings):
|
||||
def __enter__(self) -> None: ...
|
||||
|
||||
class _catch_warnings_with_records(catch_warnings):
|
||||
def __enter__(self) -> List[_Record]: ...
|
||||
def __enter__(self) -> List[WarningMessage]: ...
|
||||
|
||||
Reference in New Issue
Block a user