massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-pyright / node_modules / pyright / dist / typeshed-fallback / stdlib / smtplib.pyi
1 from _typeshed import Self
2 from email.message import Message as _Message
3 from socket import socket
4 from ssl import SSLContext
5 from types import TracebackType
6 from typing import Any, Dict, Pattern, Protocol, Sequence, Tuple, Type, Union, overload
7
8 _Reply = Tuple[int, bytes]
9 _SendErrs = Dict[str, _Reply]
10 # Should match source_address for socket.create_connection
11 _SourceAddress = Tuple[Union[bytearray, bytes, str], int]
12
13 SMTP_PORT: int
14 SMTP_SSL_PORT: int
15 CRLF: str
16 bCRLF: bytes
17
18 OLDSTYLE_AUTH: Pattern[str]
19
20 class SMTPException(OSError): ...
21 class SMTPNotSupportedError(SMTPException): ...
22 class SMTPServerDisconnected(SMTPException): ...
23
24 class SMTPResponseException(SMTPException):
25     smtp_code: int
26     smtp_error: bytes | str
27     args: tuple[int, bytes | str] | tuple[int, bytes, str]
28     def __init__(self, code: int, msg: bytes | str) -> None: ...
29
30 class SMTPSenderRefused(SMTPResponseException):
31     smtp_code: int
32     smtp_error: bytes
33     sender: str
34     args: tuple[int, bytes, str]
35     def __init__(self, code: int, msg: bytes, sender: str) -> None: ...
36
37 class SMTPRecipientsRefused(SMTPException):
38     recipients: _SendErrs
39     args: tuple[_SendErrs]
40     def __init__(self, recipients: _SendErrs) -> None: ...
41
42 class SMTPDataError(SMTPResponseException): ...
43 class SMTPConnectError(SMTPResponseException): ...
44 class SMTPHeloError(SMTPResponseException): ...
45 class SMTPAuthenticationError(SMTPResponseException): ...
46
47 def quoteaddr(addrstring: str) -> str: ...
48 def quotedata(data: str) -> str: ...
49
50 class _AuthObject(Protocol):
51     @overload
52     def __call__(self, challenge: None = ...) -> str | None: ...
53     @overload
54     def __call__(self, challenge: bytes) -> str: ...
55
56 class SMTP:
57     debuglevel: int
58     sock: socket | None
59     # Type of file should match what socket.makefile() returns
60     file: Any | None
61     helo_resp: bytes | None
62     ehlo_msg: str
63     ehlo_resp: bytes | None
64     does_esmtp: bool
65     default_port: int
66     timeout: float
67     esmtp_features: dict[str, str]
68     command_encoding: str
69     source_address: _SourceAddress | None
70     local_hostname: str
71     def __init__(
72         self,
73         host: str = ...,
74         port: int = ...,
75         local_hostname: str | None = ...,
76         timeout: float = ...,
77         source_address: _SourceAddress | None = ...,
78     ) -> None: ...
79     def __enter__(self: Self) -> Self: ...
80     def __exit__(
81         self, exc_type: Type[BaseException] | None, exc_value: BaseException | None, tb: TracebackType | None
82     ) -> None: ...
83     def set_debuglevel(self, debuglevel: int) -> None: ...
84     def connect(self, host: str = ..., port: int = ..., source_address: _SourceAddress | None = ...) -> _Reply: ...
85     def send(self, s: bytes | str) -> None: ...
86     def putcmd(self, cmd: str, args: str = ...) -> None: ...
87     def getreply(self) -> _Reply: ...
88     def docmd(self, cmd: str, args: str = ...) -> _Reply: ...
89     def helo(self, name: str = ...) -> _Reply: ...
90     def ehlo(self, name: str = ...) -> _Reply: ...
91     def has_extn(self, opt: str) -> bool: ...
92     def help(self, args: str = ...) -> bytes: ...
93     def rset(self) -> _Reply: ...
94     def noop(self) -> _Reply: ...
95     def mail(self, sender: str, options: Sequence[str] = ...) -> _Reply: ...
96     def rcpt(self, recip: str, options: Sequence[str] = ...) -> _Reply: ...
97     def data(self, msg: bytes | str) -> _Reply: ...
98     def verify(self, address: str) -> _Reply: ...
99     vrfy = verify
100     def expn(self, address: str) -> _Reply: ...
101     def ehlo_or_helo_if_needed(self) -> None: ...
102     user: str
103     password: str
104     def auth(self, mechanism: str, authobject: _AuthObject, *, initial_response_ok: bool = ...) -> _Reply: ...
105     @overload
106     def auth_cram_md5(self, challenge: None = ...) -> None: ...
107     @overload
108     def auth_cram_md5(self, challenge: bytes) -> str: ...
109     def auth_plain(self, challenge: bytes | None = ...) -> str: ...
110     def auth_login(self, challenge: bytes | None = ...) -> str: ...
111     def login(self, user: str, password: str, *, initial_response_ok: bool = ...) -> _Reply: ...
112     def starttls(self, keyfile: str | None = ..., certfile: str | None = ..., context: SSLContext | None = ...) -> _Reply: ...
113     def sendmail(
114         self,
115         from_addr: str,
116         to_addrs: str | Sequence[str],
117         msg: bytes | str,
118         mail_options: Sequence[str] = ...,
119         rcpt_options: Sequence[str] = ...,
120     ) -> _SendErrs: ...
121     def send_message(
122         self,
123         msg: _Message,
124         from_addr: str | None = ...,
125         to_addrs: str | Sequence[str] | None = ...,
126         mail_options: Sequence[str] = ...,
127         rcpt_options: Sequence[str] = ...,
128     ) -> _SendErrs: ...
129     def close(self) -> None: ...
130     def quit(self) -> _Reply: ...
131
132 class SMTP_SSL(SMTP):
133     default_port: int
134     keyfile: str | None
135     certfile: str | None
136     context: SSLContext
137     def __init__(
138         self,
139         host: str = ...,
140         port: int = ...,
141         local_hostname: str | None = ...,
142         keyfile: str | None = ...,
143         certfile: str | None = ...,
144         timeout: float = ...,
145         source_address: _SourceAddress | None = ...,
146         context: SSLContext | None = ...,
147     ) -> None: ...
148
149 LMTP_PORT: int
150
151 class LMTP(SMTP):
152     def __init__(
153         self, host: str = ..., port: int = ..., local_hostname: str | None = ..., source_address: _SourceAddress | None = ...
154     ) -> None: ...