Switch to PEP-604 syntax in python2 stubs (#5915)

Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>
This commit is contained in:
Oleg Höfling
2021-08-14 11:12:30 +02:00
committed by GitHub
parent 431c4f7fc1
commit ff63953188
235 changed files with 2473 additions and 2768 deletions

View File

@@ -1,20 +1,13 @@
from types import ModuleType, TracebackType
from typing import List, Optional, TextIO, Type, Union, overload
from typing import List, TextIO, Type, overload
from typing_extensions import Literal
from _warnings import warn as warn, warn_explicit as warn_explicit
def showwarning(
message: Union[Warning, str],
category: Type[Warning],
filename: str,
lineno: int,
file: Optional[TextIO] = ...,
line: Optional[str] = ...,
message: Warning | str, category: Type[Warning], filename: str, lineno: int, file: TextIO | None = ..., line: str | None = ...
) -> None: ...
def formatwarning(
message: Union[Warning, str], category: Type[Warning], filename: str, lineno: int, line: Optional[str] = ...
) -> str: ...
def formatwarning(message: Warning | str, category: Type[Warning], filename: str, lineno: int, line: str | None = ...) -> str: ...
def filterwarnings(
action: str, message: str = ..., category: Type[Warning] = ..., module: str = ..., lineno: int = ..., append: bool = ...
) -> None: ...
@@ -24,32 +17,32 @@ def resetwarnings() -> None: ...
class _OptionError(Exception): ...
class WarningMessage:
message: Union[Warning, str]
message: Warning | str
category: Type[Warning]
filename: str
lineno: int
file: Optional[TextIO]
line: Optional[str]
file: TextIO | None
line: str | None
def __init__(
self,
message: Union[Warning, str],
message: Warning | str,
category: Type[Warning],
filename: str,
lineno: int,
file: Optional[TextIO] = ...,
line: Optional[str] = ...,
file: TextIO | None = ...,
line: str | None = ...,
) -> None: ...
class catch_warnings:
@overload
def __new__(cls, *, record: Literal[False] = ..., module: Optional[ModuleType] = ...) -> _catch_warnings_without_records: ...
def __new__(cls, *, record: Literal[False] = ..., module: ModuleType | None = ...) -> _catch_warnings_without_records: ...
@overload
def __new__(cls, *, record: Literal[True], module: Optional[ModuleType] = ...) -> _catch_warnings_with_records: ...
def __new__(cls, *, record: Literal[True], module: ModuleType | None = ...) -> _catch_warnings_with_records: ...
@overload
def __new__(cls, *, record: bool, module: Optional[ModuleType] = ...) -> catch_warnings: ...
def __enter__(self) -> Optional[List[WarningMessage]]: ...
def __new__(cls, *, record: bool, module: ModuleType | None = ...) -> catch_warnings: ...
def __enter__(self) -> List[WarningMessage] | None: ...
def __exit__(
self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]
self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
) -> None: ...
class _catch_warnings_without_records(catch_warnings):