From acc503e88dee8c519f67ee2176b42199aa889f82 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 25 Apr 2017 15:30:25 -0700 Subject: [PATCH 1/2] stub for poplib --- stdlib/2and3/poplib.pyi | 68 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 stdlib/2and3/poplib.pyi diff --git a/stdlib/2and3/poplib.pyi b/stdlib/2and3/poplib.pyi new file mode 100644 index 000000000000..d36ad80952b5 --- /dev/null +++ b/stdlib/2and3/poplib.pyi @@ -0,0 +1,68 @@ +# Stubs for poplib (Python 2 and 3) + +from mypy_extensions import NoReturn +import socket +import ssl +import sys +from typing import Any, BinaryIO, Dict, List, Optional, Pattern, Tuple + +class error_proto(Exception): pass + +POP3_PORT: int +POP3_SSL_PORT: int +CR: bytes +LF: bytes +CRLF: bytes + + +class POP3: + if sys.version_info >= (3, 0): + encoding: str + + host: str + port: int + sock: socket.socket + file: BinaryIO + welcome: bytes + + def __init__(self, host: str, port: int = ..., timeout: float = ...) -> None: ... + def getwelcome(self) -> bytes: ... + def set_debuglevel(self, level: int) -> None: ... + def user(self, user: str) -> bytes: ... + def pass_(self, pswd: str) -> bytes: ... + def stat(self) -> Tuple[int, int]: ... + def list(self, which: Optional[str] = ...) -> bytes: ... + def retr(self, which: str) -> bytes: ... + def dele(self, which: str) -> bytes: ... + def noop(self) -> bytes: ... + def rset(self) -> bytes: ... + def quit(self) -> bytes: ... + def close(self) -> None: ... + def rpop(self, user: str) -> bytes: ... + + timestamp: Pattern[str] + + if sys.version_info < (3, 0): + def apop(self, user: str, secret: str) -> bytes: ... + else: + def apop(self, user: str, password: str) -> bytes: ... + def top(self, which: str, howmuch: int) -> bytes: ... + def uidl(self, which: Optional[str] = ...) -> bytes: ... + if sys.version_info >= (3, 5): + def utf8(self) -> bytes: ... + if sys.version_info >= (3, 4): + def capa(self) -> Dict[str, List[str]]: ... + def stls(self, context: Optional[ssl.SSLContext] = ...) -> bytes: ... + + +class POP3_SSL(POP3): + if sys.version_info >= (3, 0): + def __init__(self, host: str, port: int = ..., keyfile: Optional[str] = ..., certfile: Optional[str] = ..., + timeout: float = ..., context: Optional[ssl.SSLContext] = ...) -> None: ... + else: + def __init__(self, host: str, port: int = ..., keyfile: Optional[str] = ..., certfile: Optional[str] = ..., + timeout: float = ...) -> None: ... + + if sys.version_info >= (3, 4): + # "context" is actually the last argument, but that breaks LSP and it doesn't really matter because all the arguments are ignored + def stls(self, context: Any = ..., keyfile: Any = ..., certfile: Any = ...) -> bytes: ... From 2fb26072850aba946a13db898338f9d7fc889753 Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Thu, 27 Apr 2017 08:33:18 -0700 Subject: [PATCH 2/2] poplib: str -> Text --- stdlib/2and3/poplib.pyi | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/stdlib/2and3/poplib.pyi b/stdlib/2and3/poplib.pyi index d36ad80952b5..ab8d4fcb4e15 100644 --- a/stdlib/2and3/poplib.pyi +++ b/stdlib/2and3/poplib.pyi @@ -4,7 +4,7 @@ from mypy_extensions import NoReturn import socket import ssl import sys -from typing import Any, BinaryIO, Dict, List, Optional, Pattern, Tuple +from typing import Any, BinaryIO, Dict, List, Optional, Pattern, Text, Tuple class error_proto(Exception): pass @@ -17,50 +17,50 @@ CRLF: bytes class POP3: if sys.version_info >= (3, 0): - encoding: str + encoding: Text - host: str + host: Text port: int sock: socket.socket file: BinaryIO welcome: bytes - def __init__(self, host: str, port: int = ..., timeout: float = ...) -> None: ... + def __init__(self, host: Text, port: int = ..., timeout: float = ...) -> None: ... def getwelcome(self) -> bytes: ... def set_debuglevel(self, level: int) -> None: ... - def user(self, user: str) -> bytes: ... - def pass_(self, pswd: str) -> bytes: ... + def user(self, user: Text) -> bytes: ... + def pass_(self, pswd: Text) -> bytes: ... def stat(self) -> Tuple[int, int]: ... - def list(self, which: Optional[str] = ...) -> bytes: ... - def retr(self, which: str) -> bytes: ... - def dele(self, which: str) -> bytes: ... + def list(self, which: Optional[Text] = ...) -> bytes: ... + def retr(self, which: Text) -> bytes: ... + def dele(self, which: Text) -> bytes: ... def noop(self) -> bytes: ... def rset(self) -> bytes: ... def quit(self) -> bytes: ... def close(self) -> None: ... - def rpop(self, user: str) -> bytes: ... + def rpop(self, user: Text) -> bytes: ... - timestamp: Pattern[str] + timestamp: Pattern[Text] if sys.version_info < (3, 0): - def apop(self, user: str, secret: str) -> bytes: ... + def apop(self, user: Text, secret: Text) -> bytes: ... else: - def apop(self, user: str, password: str) -> bytes: ... - def top(self, which: str, howmuch: int) -> bytes: ... - def uidl(self, which: Optional[str] = ...) -> bytes: ... + def apop(self, user: Text, password: Text) -> bytes: ... + def top(self, which: Text, howmuch: int) -> bytes: ... + def uidl(self, which: Optional[Text] = ...) -> bytes: ... if sys.version_info >= (3, 5): def utf8(self) -> bytes: ... if sys.version_info >= (3, 4): - def capa(self) -> Dict[str, List[str]]: ... + def capa(self) -> Dict[Text, List[Text]]: ... def stls(self, context: Optional[ssl.SSLContext] = ...) -> bytes: ... class POP3_SSL(POP3): if sys.version_info >= (3, 0): - def __init__(self, host: str, port: int = ..., keyfile: Optional[str] = ..., certfile: Optional[str] = ..., + def __init__(self, host: Text, port: int = ..., keyfile: Optional[Text] = ..., certfile: Optional[Text] = ..., timeout: float = ..., context: Optional[ssl.SSLContext] = ...) -> None: ... else: - def __init__(self, host: str, port: int = ..., keyfile: Optional[str] = ..., certfile: Optional[str] = ..., + def __init__(self, host: Text, port: int = ..., keyfile: Optional[Text] = ..., certfile: Optional[Text] = ..., timeout: float = ...) -> None: ... if sys.version_info >= (3, 4):