Use PEP 585 syntax in Python 2, protobuf & _ast stubs, where possible (#6949)

This commit is contained in:
Alex Waygood
2022-01-18 15:14:03 +00:00
committed by GitHub
parent aa885ecd65
commit 8af5e0d340
264 changed files with 2217 additions and 2411 deletions

View File

@@ -1,33 +1,34 @@
import subprocess
import time
from builtins import list as List # alias to avoid name clashes with `IMAP4.list`
from socket import socket as _socket
from ssl import SSLSocket
from typing import IO, Any, Callable, Dict, List, Pattern, Text, Tuple, Type, Union
from typing import IO, Any, Callable, Pattern, Text, Union
from typing_extensions import Literal
# TODO: Commands should use their actual return types, not this type alias.
# E.g. Tuple[Literal["OK"], List[bytes]]
_CommandResults = Tuple[str, List[Any]]
# E.g. tuple[Literal["OK"], list[bytes]]
_CommandResults = tuple[str, list[Any]]
_AnyResponseData = Union[List[None], List[Union[bytes, Tuple[bytes, bytes]]]]
_AnyResponseData = Union[list[None], list[Union[bytes, tuple[bytes, bytes]]]]
class IMAP4:
error: Type[Exception] = ...
abort: Type[Exception] = ...
readonly: Type[Exception] = ...
error: type[Exception] = ...
abort: type[Exception] = ...
readonly: type[Exception] = ...
mustquote: Pattern[Text] = ...
debug: int = ...
state: str = ...
literal: Text | None = ...
tagged_commands: Dict[bytes, List[bytes] | None]
untagged_responses: Dict[str, List[bytes | Tuple[bytes, bytes]]]
tagged_commands: dict[bytes, List[bytes] | None]
untagged_responses: dict[str, List[bytes | tuple[bytes, bytes]]]
continuation_response: str = ...
is_readonly: bool = ...
tagnum: int = ...
tagpre: str = ...
tagre: Pattern[Text] = ...
welcome: bytes = ...
capabilities: Tuple[str] = ...
capabilities: tuple[str] = ...
PROTOCOL_VERSION: str = ...
def __init__(self, host: str = ..., port: int = ...) -> None: ...
def open(self, host: str = ..., port: int = ...) -> None: ...
@@ -44,7 +45,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], bytes | None]) -> 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: ...
@@ -53,24 +54,24 @@ class IMAP4:
def delete(self, mailbox: str) -> _CommandResults: ...
def deleteacl(self, mailbox: str, who: str) -> _CommandResults: ...
def expunge(self) -> _CommandResults: ...
def fetch(self, message_set: str, message_parts: str) -> Tuple[str, _AnyResponseData]: ...
def fetch(self, message_set: str, message_parts: str) -> tuple[str, _AnyResponseData]: ...
def getacl(self, mailbox: str) -> _CommandResults: ...
def getannotation(self, mailbox: str, entry: str, attribute: str) -> _CommandResults: ...
def getquota(self, root: str) -> _CommandResults: ...
def getquotaroot(self, mailbox: str) -> _CommandResults: ...
def list(self, directory: str = ..., pattern: str = ...) -> Tuple[str, _AnyResponseData]: ...
def login(self, user: str, password: str) -> Tuple[Literal["OK"], List[bytes]]: ...
def list(self, directory: str = ..., pattern: str = ...) -> tuple[str, _AnyResponseData]: ...
def login(self, user: str, password: str) -> tuple[Literal["OK"], List[bytes]]: ...
def login_cram_md5(self, user: str, password: str) -> _CommandResults: ...
def logout(self) -> Tuple[str, _AnyResponseData]: ...
def logout(self) -> tuple[str, _AnyResponseData]: ...
def lsub(self, directory: str = ..., pattern: str = ...) -> _CommandResults: ...
def myrights(self, mailbox: str) -> _CommandResults: ...
def namespace(self) -> _CommandResults: ...
def noop(self) -> Tuple[str, List[bytes]]: ...
def noop(self) -> tuple[str, List[bytes]]: ...
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: str | None, *criteria: str) -> _CommandResults: ...
def select(self, mailbox: str = ..., readonly: bool = ...) -> Tuple[str, List[bytes | None]]: ...
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: ...
@@ -126,5 +127,5 @@ class _Authenticator:
def Internaldate2tuple(resp: str) -> time.struct_time: ...
def Int2AP(num: int) -> str: ...
def ParseFlags(resp: str) -> Tuple[str]: ...
def ParseFlags(resp: str) -> tuple[str]: ...
def Time2Internaldate(date_time: float | time.struct_time | str) -> str: ...