mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 20:54:28 +08:00
Big diff: Use new "|" union syntax (#5872)
This commit is contained in:
@@ -5,7 +5,7 @@ from _typeshed import Self
|
||||
from socket import socket as _socket
|
||||
from ssl import SSLContext, SSLSocket
|
||||
from types import TracebackType
|
||||
from typing import IO, Any, Callable, Dict, List, Optional, Pattern, Tuple, Type, Union
|
||||
from typing import IO, Any, Callable, Dict, List, Pattern, Tuple, Type, Union
|
||||
from typing_extensions import Literal
|
||||
|
||||
# TODO: Commands should use their actual return types, not this type alias.
|
||||
@@ -21,9 +21,9 @@ class IMAP4:
|
||||
mustquote: Pattern[str] = ...
|
||||
debug: int = ...
|
||||
state: str = ...
|
||||
literal: Optional[str] = ...
|
||||
tagged_commands: Dict[bytes, Optional[List[bytes]]]
|
||||
untagged_responses: Dict[str, List[Union[bytes, Tuple[bytes, bytes]]]]
|
||||
literal: str | None = ...
|
||||
tagged_commands: Dict[bytes, List[bytes] | None]
|
||||
untagged_responses: Dict[str, List[bytes | Tuple[bytes, bytes]]]
|
||||
continuation_response: str = ...
|
||||
is_readonly: bool = ...
|
||||
tagnum: int = ...
|
||||
@@ -33,8 +33,8 @@ class IMAP4:
|
||||
capabilities: Tuple[str] = ...
|
||||
PROTOCOL_VERSION: str = ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def __init__(self, host: str = ..., port: int = ..., timeout: Optional[float] = ...) -> None: ...
|
||||
def open(self, host: str = ..., port: int = ..., timeout: Optional[float] = ...) -> None: ...
|
||||
def __init__(self, host: str = ..., port: int = ..., timeout: float | None = ...) -> None: ...
|
||||
def open(self, host: str = ..., port: int = ..., timeout: float | None = ...) -> None: ...
|
||||
else:
|
||||
def __init__(self, host: str = ..., port: int = ...) -> None: ...
|
||||
def open(self, host: str = ..., port: int = ...) -> None: ...
|
||||
@@ -42,7 +42,7 @@ class IMAP4:
|
||||
host: str = ...
|
||||
port: int = ...
|
||||
sock: _socket = ...
|
||||
file: Union[IO[str], IO[bytes]] = ...
|
||||
file: IO[str] | IO[bytes] = ...
|
||||
def read(self, size: int) -> bytes: ...
|
||||
def readline(self) -> bytes: ...
|
||||
def send(self, data: bytes) -> None: ...
|
||||
@@ -51,7 +51,7 @@ class IMAP4:
|
||||
def recent(self) -> _CommandResults: ...
|
||||
def response(self, code: str) -> _CommandResults: ...
|
||||
def append(self, mailbox: str, flags: str, date_time: str, message: str) -> str: ...
|
||||
def authenticate(self, mechanism: str, authobject: Callable[[bytes], Optional[bytes]]) -> Tuple[str, str]: ...
|
||||
def authenticate(self, mechanism: str, authobject: Callable[[bytes], bytes | None]) -> Tuple[str, str]: ...
|
||||
def capability(self) -> _CommandResults: ...
|
||||
def check(self) -> _CommandResults: ...
|
||||
def close(self) -> _CommandResults: ...
|
||||
@@ -61,7 +61,7 @@ class IMAP4:
|
||||
def deleteacl(self, mailbox: str, who: str) -> _CommandResults: ...
|
||||
def enable(self, capability: str) -> _CommandResults: ...
|
||||
def __enter__(self: Self) -> Self: ...
|
||||
def __exit__(self, t: Optional[Type[BaseException]], v: Optional[BaseException], tb: Optional[TracebackType]) -> None: ...
|
||||
def __exit__(self, t: Type[BaseException] | None, v: BaseException | None, tb: TracebackType | None) -> None: ...
|
||||
def expunge(self) -> _CommandResults: ...
|
||||
def fetch(self, message_set: str, message_parts: str) -> Tuple[str, _AnyResponseData]: ...
|
||||
def getacl(self, mailbox: str) -> _CommandResults: ...
|
||||
@@ -79,13 +79,13 @@ class IMAP4:
|
||||
def partial(self, message_num: str, message_part: str, start: str, length: str) -> _CommandResults: ...
|
||||
def proxyauth(self, user: str) -> _CommandResults: ...
|
||||
def rename(self, oldmailbox: str, newmailbox: str) -> _CommandResults: ...
|
||||
def search(self, charset: Optional[str], *criteria: str) -> _CommandResults: ...
|
||||
def select(self, mailbox: str = ..., readonly: bool = ...) -> Tuple[str, List[Optional[bytes]]]: ...
|
||||
def search(self, charset: str | None, *criteria: str) -> _CommandResults: ...
|
||||
def select(self, mailbox: str = ..., readonly: bool = ...) -> Tuple[str, List[bytes | None]]: ...
|
||||
def setacl(self, mailbox: str, who: str, what: str) -> _CommandResults: ...
|
||||
def setannotation(self, *args: str) -> _CommandResults: ...
|
||||
def setquota(self, root: str, limits: str) -> _CommandResults: ...
|
||||
def sort(self, sort_criteria: str, charset: str, *search_criteria: str) -> _CommandResults: ...
|
||||
def starttls(self, ssl_context: Optional[Any] = ...) -> Tuple[Literal["OK"], List[None]]: ...
|
||||
def starttls(self, ssl_context: Any | None = ...) -> Tuple[Literal["OK"], List[None]]: ...
|
||||
def status(self, mailbox: str, names: str) -> _CommandResults: ...
|
||||
def store(self, message_set: str, command: str, flags: str) -> _CommandResults: ...
|
||||
def subscribe(self, mailbox: str) -> _CommandResults: ...
|
||||
@@ -105,19 +105,19 @@ class IMAP4_SSL(IMAP4):
|
||||
self,
|
||||
host: str = ...,
|
||||
port: int = ...,
|
||||
keyfile: Optional[str] = ...,
|
||||
certfile: Optional[str] = ...,
|
||||
ssl_context: Optional[SSLContext] = ...,
|
||||
timeout: Optional[float] = ...,
|
||||
keyfile: str | None = ...,
|
||||
certfile: str | None = ...,
|
||||
ssl_context: SSLContext | None = ...,
|
||||
timeout: float | None = ...,
|
||||
) -> None: ...
|
||||
else:
|
||||
def __init__(
|
||||
self,
|
||||
host: str = ...,
|
||||
port: int = ...,
|
||||
keyfile: Optional[str] = ...,
|
||||
certfile: Optional[str] = ...,
|
||||
ssl_context: Optional[SSLContext] = ...,
|
||||
keyfile: str | None = ...,
|
||||
certfile: str | None = ...,
|
||||
ssl_context: SSLContext | None = ...,
|
||||
) -> None: ...
|
||||
host: str = ...
|
||||
port: int = ...
|
||||
@@ -125,9 +125,9 @@ class IMAP4_SSL(IMAP4):
|
||||
sslobj: SSLSocket = ...
|
||||
file: IO[Any] = ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def open(self, host: str = ..., port: Optional[int] = ..., timeout: Optional[float] = ...) -> None: ...
|
||||
def open(self, host: str = ..., port: int | None = ..., timeout: float | None = ...) -> None: ...
|
||||
else:
|
||||
def open(self, host: str = ..., port: Optional[int] = ...) -> None: ...
|
||||
def open(self, host: str = ..., port: int | None = ...) -> None: ...
|
||||
def read(self, size: int) -> bytes: ...
|
||||
def readline(self) -> bytes: ...
|
||||
def send(self, data: bytes) -> None: ...
|
||||
@@ -146,9 +146,9 @@ class IMAP4_stream(IMAP4):
|
||||
writefile: IO[Any] = ...
|
||||
readfile: IO[Any] = ...
|
||||
if sys.version_info >= (3, 9):
|
||||
def open(self, host: Optional[str] = ..., port: Optional[int] = ..., timeout: Optional[float] = ...) -> None: ...
|
||||
def open(self, host: str | None = ..., port: int | None = ..., timeout: float | None = ...) -> None: ...
|
||||
else:
|
||||
def open(self, host: Optional[str] = ..., port: Optional[int] = ...) -> None: ...
|
||||
def open(self, host: str | None = ..., port: int | None = ...) -> None: ...
|
||||
def read(self, size: int) -> bytes: ...
|
||||
def readline(self) -> bytes: ...
|
||||
def send(self, data: bytes) -> None: ...
|
||||
@@ -164,4 +164,4 @@ class _Authenticator:
|
||||
def Internaldate2tuple(resp: str) -> time.struct_time: ...
|
||||
def Int2AP(num: int) -> str: ...
|
||||
def ParseFlags(resp: str) -> Tuple[str]: ...
|
||||
def Time2Internaldate(date_time: Union[float, time.struct_time, str]) -> str: ...
|
||||
def Time2Internaldate(date_time: float | time.struct_time | str) -> str: ...
|
||||
|
||||
Reference in New Issue
Block a user