mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-09 05:24:52 +08:00
Complete smtplib and sync with 3.5+ (#2371)
This commit is contained in:
committed by
Jelle Zijlstra
parent
047040887b
commit
b0e9998c99
@@ -1,10 +1,15 @@
|
||||
from email.message import Message as _Message
|
||||
from socket import socket
|
||||
from ssl import SSLContext
|
||||
from typing import (
|
||||
Any, AnyStr, Dict, Generic, List, Optional, Sequence, Tuple, Union,
|
||||
Pattern)
|
||||
import sys
|
||||
|
||||
_Reply = Tuple[int, bytes]
|
||||
_SendErrs = Dict[str, _Reply]
|
||||
# Should match source_address for socket.create_connection
|
||||
_SourceAddress = Tuple[Union[bytearray, bytes, str], int]
|
||||
|
||||
SMTP_PORT: int
|
||||
SMTP_SSL_PORT: int
|
||||
@@ -17,21 +22,21 @@ class SMTPException(OSError): ...
|
||||
class SMTPServerDisconnected(SMTPException): ...
|
||||
|
||||
class SMTPResponseException(SMTPException):
|
||||
smtp_code = ... # type: int
|
||||
smtp_error = ... # type: Union[bytes, str]
|
||||
args = ... # type: Union[Tuple[int, Union[bytes, str]], Tuple[int, bytes, str]]
|
||||
smtp_code: int
|
||||
smtp_error: Union[bytes, str]
|
||||
args: Union[Tuple[int, Union[bytes, str]], Tuple[int, bytes, str]]
|
||||
def __init__(self, code: int, msg: Union[bytes, str]) -> None: ...
|
||||
|
||||
class SMTPSenderRefused(SMTPResponseException):
|
||||
smtp_code = ... # type: int
|
||||
smtp_error = ... # type: bytes
|
||||
sender = ... # type: str
|
||||
args = ... # type: Tuple[int, bytes, str]
|
||||
smtp_code: int
|
||||
smtp_error: bytes
|
||||
sender: str
|
||||
args: Tuple[int, bytes, str]
|
||||
def __init__(self, code: int, msg: bytes, sender: str) -> None: ...
|
||||
|
||||
class SMTPRecipientsRefused(SMTPException):
|
||||
recipients = ... # type: _SendErrs
|
||||
args = ... # type: Tuple[_SendErrs]
|
||||
recipients: _SendErrs
|
||||
args: Tuple[_SendErrs]
|
||||
def __init__(self, recipients: _SendErrs) -> None: ...
|
||||
|
||||
class SMTPDataError(SMTPResponseException): ...
|
||||
@@ -39,48 +44,55 @@ class SMTPConnectError(SMTPResponseException): ...
|
||||
class SMTPHeloError(SMTPResponseException): ...
|
||||
class SMTPAuthenticationError(SMTPResponseException): ...
|
||||
|
||||
def quoteaddr(addrstring): ...
|
||||
def quotedata(data): ...
|
||||
def quoteaddr(addrstring: str) -> str: ...
|
||||
def quotedata(data: str) -> str: ...
|
||||
|
||||
class SMTP:
|
||||
debuglevel = ... # type: int
|
||||
file = ... # type: Any
|
||||
helo_resp = ... # type: Any
|
||||
ehlo_msg = ... # type: Any
|
||||
ehlo_resp = ... # type: Any
|
||||
does_esmtp = ... # type: Any
|
||||
default_port = ... # type: Any
|
||||
timeout = ... # type: float
|
||||
esmtp_features = ... # type: Any
|
||||
source_address = ... # type: Any
|
||||
local_hostname = ... # type: Any
|
||||
debuglevel: int
|
||||
# Type of file should match what socket.makefile() returns
|
||||
file: Any
|
||||
helo_resp: Optional[bytes]
|
||||
ehlo_msg: str
|
||||
ehlo_resp: Optional[bytes]
|
||||
does_esmtp: int
|
||||
default_port: int
|
||||
timeout: float
|
||||
esmtp_features: Dict[str, str]
|
||||
source_address: Optional[_SourceAddress]
|
||||
local_hostname: str
|
||||
def __init__(self, host: str = ..., port: int = ...,
|
||||
local_hostname: Optional[str] = ..., timeout: float = ...,
|
||||
source_address: Tuple[str, int] = ...) -> None: ...
|
||||
def __enter__(self): ...
|
||||
def __exit__(self, *args): ...
|
||||
source_address: Optional[_SourceAddress] = ...) -> None: ...
|
||||
def __enter__(self) -> SMTP: ...
|
||||
def __exit__(self, *args) -> None: ...
|
||||
def set_debuglevel(self, debuglevel: int) -> None: ...
|
||||
sock = ... # type: Any
|
||||
def connect(self, host=..., port=..., source_address=...): ...
|
||||
def send(self, s): ...
|
||||
def putcmd(self, cmd, args=...): ...
|
||||
sock: Optional[socket]
|
||||
def connect(self, host: str = ..., port: int = ...,
|
||||
source_address: Optional[_SourceAddress] = ...) -> _Reply: ...
|
||||
def send(self, s: Union[bytes, str]) -> None: ...
|
||||
def putcmd(self, cmd: str, args: str = ...) -> None: ...
|
||||
def getreply(self) -> _Reply: ...
|
||||
def docmd(self, cmd, args=...): ...
|
||||
def helo(self, name=...): ...
|
||||
def ehlo(self, name=...): ...
|
||||
def has_extn(self, opt): ...
|
||||
def help(self, args=...): ...
|
||||
def docmd(self, cmd: str, args: str = ...) -> _Reply: ...
|
||||
def helo(self, name: str = ...) -> _Reply: ...
|
||||
def ehlo(self, name: str = ...) -> _Reply: ...
|
||||
def has_extn(self, opt: str) -> bool: ...
|
||||
def help(self, args: str = ...) -> bytes: ...
|
||||
def rset(self) -> _Reply: ...
|
||||
def noop(self) -> _Reply: ...
|
||||
def mail(self, sender: str, options: Sequence[str] = ...) -> _Reply: ...
|
||||
def rcpt(self, recip: str, options: Sequence[str] = ...) -> _Reply: ...
|
||||
def data(self, msg): ...
|
||||
def verify(self, address): ...
|
||||
vrfy = ... # type: Any
|
||||
def expn(self, address): ...
|
||||
def ehlo_or_helo_if_needed(self): ...
|
||||
def login(self, user, password): ...
|
||||
def starttls(self, keyfile=..., certfile=..., context=...): ...
|
||||
def data(self, msg: Union[bytes, str]) -> _Reply: ...
|
||||
def verify(self, address: str) -> _Reply: ...
|
||||
vrfy = verify
|
||||
def expn(self, address: str) -> _Reply: ...
|
||||
def ehlo_or_helo_if_needed(self) -> None: ...
|
||||
if sys.version_info >= (3, 5):
|
||||
def login(self, user: str, password: str, *,
|
||||
initial_response_ok: bool = ...) -> _Reply: ...
|
||||
else:
|
||||
def login(self, user: str, password: str) -> _Reply: ...
|
||||
def starttls(self, keyfile: Optional[str] = ..., certfile: Optional[str] = ...,
|
||||
context: Optional[SSLContext] = ...) -> _Reply: ...
|
||||
def sendmail(self, from_addr: str, to_addrs: Union[str, Sequence[str]],
|
||||
msg: Union[bytes, str], mail_options: Sequence[str] = ...,
|
||||
rcpt_options: List[str] = ...) -> _SendErrs: ...
|
||||
@@ -88,22 +100,21 @@ class SMTP:
|
||||
to_addrs: Optional[Union[str, Sequence[str]]] = ...,
|
||||
mail_options: List[str] = ...,
|
||||
rcpt_options: Sequence[str] = ...) -> _SendErrs: ...
|
||||
def close(self): ...
|
||||
def close(self) -> None: ...
|
||||
def quit(self) -> _Reply: ...
|
||||
|
||||
class SMTP_SSL(SMTP):
|
||||
default_port = ... # type: Any
|
||||
keyfile = ... # type: Any
|
||||
certfile = ... # type: Any
|
||||
context = ... # type: Any
|
||||
def __init__(self, host=..., port=..., local_hostname=..., keyfile=..., certfile=...,
|
||||
timeout=..., source_address=..., context=...): ...
|
||||
|
||||
class LMTP(SMTP):
|
||||
ehlo_msg = ... # type: Any
|
||||
keyfile: Optional[str]
|
||||
certfile: Optional[str]
|
||||
context: SSLContext
|
||||
def __init__(self, host: str = ..., port: int = ...,
|
||||
local_hostname: Optional[str] = ...,
|
||||
source_address: Optional[Tuple[str, int]] = ...) -> None: ...
|
||||
sock = ... # type: Any
|
||||
file = ... # type: Any
|
||||
def connect(self, host=..., port=..., source_address=...): ...
|
||||
keyfile: Optional[str] = ..., certfile: Optional[str] = ...,
|
||||
timeout: float = ...,
|
||||
source_address: Optional[_SourceAddress] = ...,
|
||||
context: Optional[SSLContext] = ...) -> None: ...
|
||||
|
||||
class LMTP(SMTP):
|
||||
def __init__(self, host: str = ..., port: int = ...,
|
||||
local_hostname: Optional[str] = ...,
|
||||
source_address: Optional[_SourceAddress] = ...) -> None: ...
|
||||
|
||||
Reference in New Issue
Block a user