From abac8764ffe3f540fe4a3fed7daf1a5f3200ae7b Mon Sep 17 00:00:00 2001 From: tharvik Date: Tue, 31 May 2016 15:16:31 +0200 Subject: [PATCH 1/4] complete http.client --- stdlib/3/http/client.pyi | 266 +++++++++++++++++++++++++++------------ 1 file changed, 189 insertions(+), 77 deletions(-) diff --git a/stdlib/3/http/client.pyi b/stdlib/3/http/client.pyi index 1c83fd4e708a..c9b92d6c7976 100644 --- a/stdlib/3/http/client.pyi +++ b/stdlib/3/http/client.pyi @@ -1,101 +1,213 @@ # Stubs for http.client (Python 3.4) -from typing import Any, Dict +from typing import ( + Any, Dict, IO, Iterable, List, Iterator, Mapping, Optional, Tuple, TypeVar, + Union, + overload, +) import email.message import io +import sys +import ssl +import types + +_DataType = Union[bytes, IO[Any], Iterable[bytes], str] +_T = TypeVar('_T') + +HTTP_PORT = ... # type: int +HTTPS_PORT = ... # type: int + +CONTINUE = ... # type: int +SWITCHING_PROTOCOLS = ... # type: int +PROCESSING = ... # type: int + +OK = ... # type: int +CREATED = ... # type: int +ACCEPTED = ... # type: int +NON_AUTHORITATIVE_INFORMATION = ... # type: int +NO_CONTENT = ... # type: int +RESET_CONTENT = ... # type: int +PARTIAL_CONTENT = ... # type: int +MULTI_STATUS = ... # type: int +IM_USED = ... # type: int + +MULTIPLE_CHOICES = ... # type: int +MOVED_PERMANENTLY = ... # type: int +FOUND = ... # type: int +SEE_OTHER = ... # type: int +NOT_MODIFIED = ... # type: int +USE_PROXY = ... # type: int +TEMPORARY_REDIRECT = ... # type: int + +BAD_REQUEST = ... # type: int +UNAUTHORIZED = ... # type: int +PAYMENT_REQUIRED = ... # type: int +FORBIDDEN = ... # type: int +NOT_FOUND = ... # type: int +METHOD_NOT_ALLOWED = ... # type: int +NOT_ACCEPTABLE = ... # type: int +PROXY_AUTHENTICATION_REQUIRED = ... # type: int +REQUEST_TIMEOUT = ... # type: int +CONFLICT = ... # type: int +GONE = ... # type: int +LENGTH_REQUIRED = ... # type: int +PRECONDITION_FAILED = ... # type: int +REQUEST_ENTITY_TOO_LARGE = ... # type: int +REQUEST_URI_TOO_LONG = ... # type: int +UNSUPPORTED_MEDIA_TYPE = ... # type: int +REQUESTED_RANGE_NOT_SATISFIABLE = ... # type: int +EXPECTATION_FAILED = ... # type: int +UNPROCESSABLE_ENTITY = ... # type: int +LOCKED = ... # type: int +FAILED_DEPENDENCY = ... # type: int +UPGRADE_REQUIRED = ... # type: int +PRECONDITION_REQUIRED = ... # type: int +TOO_MANY_REQUESTS = ... # type: int +REQUEST_HEADER_FIELDS_TOO_LARGE = ... # type: int + +INTERNAL_SERVER_ERROR = ... # type: int +NOT_IMPLEMENTED = ... # type: int +BAD_GATEWAY = ... # type: int +SERVICE_UNAVAILABLE = ... # type: int +GATEWAY_TIMEOUT = ... # type: int +HTTP_VERSION_NOT_SUPPORTED = ... # type: int +INSUFFICIENT_STORAGE = ... # type: int +NOT_EXTENDED = ... # type: int +NETWORK_AUTHENTICATION_REQUIRED = ... # type: int responses = ... # type: Dict[int, str] -class HTTPMessage(email.message.Message): - def getallmatchingheaders(self, name): ... - -class HTTPResponse(io.RawIOBase): - fp = ... # type: Any - debuglevel = ... # type: Any - headers = ... # type: Any - version = ... # type: Any - status = ... # type: Any - reason = ... # type: Any - chunked = ... # type: Any - chunk_left = ... # type: Any - length = ... # type: Any - will_close = ... # type: Any - def __init__(self, sock, debuglevel=..., method=..., url=...) -> None: ... - code = ... # type: Any - def begin(self): ... - def close(self): ... - def flush(self): ... - def readable(self): ... - def isclosed(self): ... - def read(self, amt=...): ... - def readinto(self, b): ... - def fileno(self): ... - def getheader(self, name, default=...): ... - def getheaders(self): ... - def __iter__(self): ... - def info(self): ... - def geturl(self): ... - def getcode(self): ... +class HTTPMessage(email.message.Message): ... + +# TODO uncomment when mypy handle conditionals +#if sys.version_info >= (3, 5): +# class HTTPResponse(io.BufferedIOBase): +# msg = ... # type: HTTPMessage +# version = ... # type: int +# debuglevel = ... # type: int +# closed = ... # type: bool +# status = ... # type: int +# reason = ... # type: str +# def read(self, amt: Optional[int] = ...) -> bytes: ... +# def readinto(self, b: bytearray) -> int: ... +# @overload +# def getheader(self, name: str) -> Optional[str]: ... +# @overload +# def getheader(self, name: str, default: _T) -> Union[str, _T]: ... +# def getheaders(self) -> List[Tuple[str, str]]: ... +# def fileno(self) -> int: ... +# def __iter__(self) -> Iterator[bytes]: ... +# def __enter__(self) -> 'HTTPResponse': ... +# def __exit__(self, exc_type: Optional[type], +# exc_val: Optional[Exception], +# exc_tb: Optional[types.TracebackType]) -> bool: ... +#else: +# class HTTPResponse: +# msg = ... # type: HTTPMessage +# version = ... # type: int +# debuglevel = ... # type: int +# closed = ... # type: bool +# status = ... # type: int +# reason = ... # type: str +# def read(self, amt: Optional[int] = ...) -> bytes: ... +# if sys.version_info >= (3, 3): +# def readinto(self, b: bytearray) -> int: ... +# @overload +# def getheader(self, name: str) -> Optional[str]: ... +# @overload +# def getheader(self, name: str, default: _T) -> Union[str, _T]: ... +# def getheaders(self) -> List[Tuple[str, str]]: ... +# def fileno(self) -> int: ... +# def __iter__(self) -> Iterator[bytes]: ... +# def __enter__(self) -> 'HTTPResponse': ... +# def __exit__(self, exc_type: Optional[type], +# exc_val: Optional[Exception], +# exc_tb: Optional[types.TracebackType]) -> bool: ... +class HTTPResponse(io.BufferedIOBase): + msg = ... # type: HTTPMessage + version = ... # type: int + debuglevel = ... # type: int + closed = ... # type: bool + status = ... # type: int + reason = ... # type: str + def read(self, amt: Optional[int] = ...) -> bytes: ... + def readinto(self, b: bytearray) -> int: ... + @overload + def getheader(self, name: str) -> Optional[str]: ... + @overload + def getheader(self, name: str, default: _T) -> Union[str, _T]: ... + def getheaders(self) -> List[Tuple[str, str]]: ... + def fileno(self) -> int: ... + def __iter__(self) -> Iterator[bytes]: ... + def __enter__(self) -> 'HTTPResponse': ... + def __exit__(self, exc_type: Optional[type], + exc_val: Optional[Exception], + exc_tb: Optional[types.TracebackType]) -> bool: ... class HTTPConnection: - response_class = ... # type: Any - default_port = ... # type: Any - auto_open = ... # type: Any - debuglevel = ... # type: Any - mss = ... # type: Any - timeout = ... # type: Any - source_address = ... # type: Any - sock = ... # type: Any - def __init__(self, host, port=..., timeout=..., source_address=...) -> None: ... - def set_tunnel(self, host, port=..., headers=...): ... - def set_debuglevel(self, level): ... - def connect(self): ... - def close(self): ... - def send(self, data): ... - def putrequest(self, method, url, skip_host=..., skip_accept_encoding=...): ... - def putheader(self, header, *values): ... - def endheaders(self, message_body=...): ... - def request(self, method, url, body=..., headers=...): ... - def getresponse(self): ... + if sys.version_info >= (3, 4): + def __init__(self, # type: ignore + host: str, port: Optional[int] = ..., + timeout: int = ..., + source_address: Optional[Tuple[str, int]] = ...) \ + -> None: ... + else: + def __init__(self, # type: ignore + host: str, port: Optional[int] = ..., + strict: bool = ..., timeout: int = ..., + source_address: Optional[Tuple[str, int]] = ...) \ + -> None: ... + def request(self, method: str, url: str, + body: Optional[_DataType] = ..., + headers: Mapping[str, str] = ...) -> None: ... + def getresponse(self) -> HTTPResponse: ... + def set_debuglevel(self, level: int) -> None: ... + def set_tunnel(self, host: str, port: Optional[int] = ..., + headers: Optional[Mapping[str, str]] = ...) -> None: ... + def connect(self) -> None: ... + def close(self) -> None: ... + def putrequest(self, request: str, selector: str, skip_host: bool = ..., + skip_accept_encoding: bool = ...) -> None: ... + def putheader(self, header: str, *argument: str) -> None: ... + def endheaders(self, message_body: Optional[_DataType] = ...) -> None: ... + def send(self, data: _DataType) -> None: ... class HTTPSConnection(HTTPConnection): - default_port = ... # type: Any - key_file = ... # type: Any - cert_file = ... # type: Any - def __init__(self, host, port=..., key_file=..., cert_file=..., timeout=..., - source_address=..., *, context=..., check_hostname=...): ... - sock = ... # type: Any - def connect(self): ... + if sys.version_info >= (3, 4): + def __init__(self, # type: ignore + host: str, port: Optional[int] = ..., + key_file: Optional[str] = ..., + cert_file: Optional[str] = ..., + timeout: int = ..., + source_address: Optional[Tuple[str, int]] = ..., + *, context: Optional[ssl.SSLContext] = ..., + check_hostname: Optional[bool] = ...) -> None: ... + else: + def __init__(self, # type: ignore + host: str, port: Optional[int] = ..., + key_file: Optional[str] = ..., + cert_file: Optional[str] = ..., + strict: bool = ..., timeout: int = ..., + source_address: Optional[Tuple[str, int]] = ..., + *, context: Optional[ssl.SSLContext] = ..., + check_hostname: Optional[bool] = ...) -> None: ... class HTTPException(Exception): ... + class NotConnected(HTTPException): ... class InvalidURL(HTTPException): ... - -class UnknownProtocol(HTTPException): - args = ... # type: Any - version = ... # type: Any - def __init__(self, version) -> None: ... - +class UnknownProtocol(HTTPException): ... class UnknownTransferEncoding(HTTPException): ... class UnimplementedFileMode(HTTPException): ... - -class IncompleteRead(HTTPException): - args = ... # type: Any - partial = ... # type: Any - expected = ... # type: Any - def __init__(self, partial, expected=...) -> None: ... +class IncompleteRead(HTTPException): ... class ImproperConnectionState(HTTPException): ... class CannotSendRequest(ImproperConnectionState): ... class CannotSendHeader(ImproperConnectionState): ... class ResponseNotReady(ImproperConnectionState): ... -class BadStatusLine(HTTPException): - args = ... # type: Any - line = ... # type: Any - def __init__(self, line) -> None: ... - -class LineTooLong(HTTPException): - def __init__(self, line_type) -> None: ... +class BadStatusLine(HTTPException): ... +class LineTooLong(HTTPException): ... -error = HTTPException +if sys.version_info >= (3, 5): + class RemoteDisconnected(ConnectionResetError, BadStatusLine): ... From e2a7522d9db1f97cf0ed16b53c8df139fed189de Mon Sep 17 00:00:00 2001 From: tharvik Date: Tue, 31 May 2016 16:37:05 +0200 Subject: [PATCH 2/4] complete http.server --- stdlib/3/http/server.pyi | 63 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 stdlib/3/http/server.pyi diff --git a/stdlib/3/http/server.pyi b/stdlib/3/http/server.pyi new file mode 100644 index 000000000000..2f1d0c2a345c --- /dev/null +++ b/stdlib/3/http/server.pyi @@ -0,0 +1,63 @@ +# Stubs for http.server (Python 3.4) + +from typing import Any, BinaryIO, Dict, List, Mapping, Optional, Tuple, Union +import socketserver +import email.message + +class HTTPServer(socketserver.TCPServer): + server_name = ... # type: str + server_port = ... # type: int + def __init__(self, server_address: Tuple[str, int], + RequestHandlerClass: type) -> None: ... + +class BaseHTTPRequestHandler: + client_address = ... # type: Tuple[str, int] + server = ... # type: socketserver.BaseServer + close_connection = ... # type: bool + requestline = ... # type: str + command = ... # type: str + path = ... # type: str + request_version = ... # type: str + headers = ... # type: email.message.Message + rfile = ... # type: BinaryIO + wfile = ... # type: BinaryIO + server_version = ... # type: str + sys_version = ... # type: str + error_message_format = ... # type: str + error_content_type = ... # type: str + protocol_version = ... # type: str + MessageClass = ... # type: type + responses = ... # type: Mapping[int, Tuple[str, str]] + def __init__(self, request: bytes, client_address: Tuple[str, int], + server: socketserver.BaseServer) -> None: ... + def handle(self) -> None: ... + def handle_one_request(self) -> None: ... + def handle_expect_100(self) -> bool: ... + def send_error(self, code: int, message: Optional[str] = ..., + explain: Optional[str] = ...) -> None: ... + def send_response(self, code: int, + message: Optional[str] = ...) -> None: ... + def send_header(self, keyword: str, value: str) -> None: ... + def send_response_only(self, code: int, + message: Optional[str] = ...) -> None: ... + def end_headers(self) -> None: ... + def flush_headers(self) -> None: ... + def log_request(self, code: Union[int, str] = ..., + size: Union[int, str] = ...) -> None: ... + def log_error(self, format: str, *args: Any) -> None: ... + def log_message(self, format: str, *args: Any) -> None: ... + def version_string(self) -> str: ... + def date_time_string(self, timestamp: Optional[int] = ...) -> str: ... + def log_date_time_string(self) -> str: ... + def address_string(self) -> str: ... + +class SimpleHTTPRequestHandler(BaseHTTPRequestHandler): + extensions_map = ... # type: Dict[str, str] + def __init__(self, request: bytes, client_address: Tuple[str, int], + server: socketserver.BaseServer) -> None: ... + def do_GET(self) -> None: ... + def do_HEAD(self) -> None: ... + +class CGIHTTPRequestHandler(SimpleHTTPRequestHandler): + cgi_directories = ... # type: List[str] + def do_POST(self) -> None: ... From 5ca300cd3a201fd4ede4c619584818f45d9c4208 Mon Sep 17 00:00:00 2001 From: tharvik Date: Tue, 31 May 2016 17:10:33 +0200 Subject: [PATCH 3/4] complete http.cookies --- stdlib/3/http/cookies.pyi | 63 +++++++++++++++------------------------ 1 file changed, 24 insertions(+), 39 deletions(-) diff --git a/stdlib/3/http/cookies.pyi b/stdlib/3/http/cookies.pyi index e7e785546bfe..50bc0abe51bf 100644 --- a/stdlib/3/http/cookies.pyi +++ b/stdlib/3/http/cookies.pyi @@ -1,46 +1,31 @@ # Stubs for http.cookies (Python 3.5) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. -from typing import Any +from typing import Generic, Mapping, MutableMapping, Optional, TypeVar, Union + +_DataType = Union[str, Mapping[str, Union[str, 'Morsel']]] +_T = TypeVar('_T') class CookieError(Exception): ... -class Morsel(dict): - def __init__(self): ... - @property - def key(self): ... - @key.setter - def key(self, key): ... - @property - def value(self): ... - @value.setter - def value(self, value): ... - @property - def coded_value(self): ... - @coded_value.setter - def coded_value(self, coded_value): ... - def __setitem__(self, K, V): ... - def setdefault(self, key, val=None): ... - def __eq__(self, morsel): ... - __ne__ = ... # type: Any - def copy(self): ... - def update(self, values): ... - def isReservedKey(self, K): ... - def set(self, key, val, coded_val, LegalChars=...): ... - def output(self, attrs=None, header=''): ... - def js_output(self, attrs=None): ... - def OutputString(self, attrs=None): ... +class Morsel(Dict[str, str], Generic[_T]): + value = ... # type: str + coded_value = ... # type: _T + key = ... # type: str + def set(self, key: str, val: str, coded_val: _T) -> None: ... + def isReservedKey(self, K: str) -> bool: ... + def output(self, attrs: Optional[List[str]] = ..., + header: str = ...) -> str: ... + def js_output(self, attrs: Optional[List[str]] = ...) -> str: ... + def OutputString(self, attrs: Optional[List[str]] = ...) -> str: ... -class BaseCookie(dict): - def value_decode(self, val): ... - def value_encode(self, val): ... - def __init__(self, input=None): ... - def __setitem__(self, key, value): ... - def output(self, attrs=None, header='', sep=''): ... - def js_output(self, attrs=None): ... - def load(self, rawdata): ... +class BaseCookie(MutableMapping[str, Morsel], Generic[_T]): + def __init__(self, input: Optional[_DataType] = ...) -> None: ... + def value_decode(self, val: str) -> _T: ... + def value_encode(self, val: _T) -> str: ... + def output(self, attrs: Optional[List[str]] = ..., header: str = ..., + sep: str = ...) -> str: ... + def js_output(self, attrs: Optional[List[str]] = ...) -> str: ... + def load(self, rawdata: _DataType) -> None: ... + def __setitem__(self, key: str, value: Union[str, Morsel]) -> None: ... -class SimpleCookie(BaseCookie): - def value_decode(self, val): ... - def value_encode(self, val): ... +class SimpleCookie(BaseCookie): ... From 35ab84d62034a1f0026011ee2117f68ed3a9cf64 Mon Sep 17 00:00:00 2001 From: tharvik Date: Wed, 1 Jun 2016 15:12:00 +0200 Subject: [PATCH 4/4] complete http.cookiejar --- stdlib/3/http/cookiejar.pyi | 213 +++++++++++++++++------------------- 1 file changed, 103 insertions(+), 110 deletions(-) diff --git a/stdlib/3/http/cookiejar.pyi b/stdlib/3/http/cookiejar.pyi index 8e56a33d7afd..3761e089bfe8 100644 --- a/stdlib/3/http/cookiejar.pyi +++ b/stdlib/3/http/cookiejar.pyi @@ -1,121 +1,114 @@ # Stubs for http.cookiejar (Python 3.4) -# -# NOTE: This dynamically typed stub was automatically generated by stubgen. -from typing import Any +from typing import Iterable, Iterator, Optional, Sequence, Tuple, TypeVar, Union, overload +from http.client import HTTPResponse +import sys +from urllib.request import Request -class Cookie: - version = ... # type: Any - name = ... # type: Any - value = ... # type: Any - port = ... # type: Any - port_specified = ... # type: Any - domain = ... # type: Any - domain_specified = ... # type: Any - domain_initial_dot = ... # type: Any - path = ... # type: Any - path_specified = ... # type: Any - secure = ... # type: Any - expires = ... # type: Any - discard = ... # type: Any - comment = ... # type: Any - comment_url = ... # type: Any - rfc2109 = ... # type: Any - def __init__(self, version, name, value, port, port_specified, domain, domain_specified, - domain_initial_dot, path, path_specified, secure, expires, discard, comment, - comment_url, rest, rfc2109=...): ... - def has_nonstandard_attr(self, name): ... - def get_nonstandard_attr(self, name, default=...): ... - def set_nonstandard_attr(self, name, value): ... - def is_expired(self, now=...): ... +_T = TypeVar('_T') -class CookiePolicy: - def set_ok(self, cookie, request): ... - def return_ok(self, cookie, request): ... - def domain_return_ok(self, domain, request): ... - def path_return_ok(self, path, request): ... +# TODO uncomment when mypy handles conditionals +#if sys.version_info >= (3, 3): +# class LoadError(OSError): ... +#else: +# class LoadError(IOError): ... +class LoadError(OSError): ... -class DefaultCookiePolicy(CookiePolicy): - DomainStrictNoDots = ... # type: Any - DomainStrictNonDomain = ... # type: Any - DomainRFC2965Match = ... # type: Any - DomainLiberal = ... # type: Any - DomainStrict = ... # type: Any - netscape = ... # type: Any - rfc2965 = ... # type: Any - rfc2109_as_netscape = ... # type: Any - hide_cookie2 = ... # type: Any - strict_domain = ... # type: Any - strict_rfc2965_unverifiable = ... # type: Any - strict_ns_unverifiable = ... # type: Any - strict_ns_domain = ... # type: Any - strict_ns_set_initial_dollar = ... # type: Any - strict_ns_set_path = ... # type: Any - def __init__(self, blocked_domains=..., allowed_domains=..., netscape=..., rfc2965=..., - rfc2109_as_netscape=..., hide_cookie2=..., strict_domain=..., - strict_rfc2965_unverifiable=..., strict_ns_unverifiable=..., - strict_ns_domain=..., strict_ns_set_initial_dollar=..., - strict_ns_set_path=...): ... - def blocked_domains(self): ... - def set_blocked_domains(self, blocked_domains): ... - def is_blocked(self, domain): ... - def allowed_domains(self): ... - def set_allowed_domains(self, allowed_domains): ... - def is_not_allowed(self, domain): ... - def set_ok(self, cookie, request): ... - def set_ok_version(self, cookie, request): ... - def set_ok_verifiability(self, cookie, request): ... - def set_ok_name(self, cookie, request): ... - def set_ok_path(self, cookie, request): ... - def set_ok_domain(self, cookie, request): ... - def set_ok_port(self, cookie, request): ... - def return_ok(self, cookie, request): ... - def return_ok_version(self, cookie, request): ... - def return_ok_verifiability(self, cookie, request): ... - def return_ok_secure(self, cookie, request): ... - def return_ok_expires(self, cookie, request): ... - def return_ok_port(self, cookie, request): ... - def return_ok_domain(self, cookie, request): ... - def domain_return_ok(self, domain, request): ... - def path_return_ok(self, path, request): ... -class Absent: ... +class CookieJar(Iterable['Cookie']): + def __init__(self, policy: Optional['CookiePolicy'] = ...) -> None: ... + def add_cookie_header(self, request: Request) -> None: ... + def extract_cookies(self, response: HTTPResponse, + request: Request) -> None: ... + def set_policy(self, policy: 'CookiePolicy') -> None: ... + def make_cookies(self, response: HTTPResponse, + request: Request) -> Sequence['Cookie']: ... + def set_cookie(self, cookie: 'Cookie') -> None: ... + def set_cookie_if_ok(self, cookie: 'Cookie', + request: Request) -> None: ... + def clear(self, domain: str = ..., path: str = ..., + name: str = ...) -> None: ... + def clear_session_cookies(self) -> None: ... + def __iter__(self) -> Iterator['Cookie']: ... -class CookieJar: - non_word_re = ... # type: Any - quote_re = ... # type: Any - strict_domain_re = ... # type: Any - domain_re = ... # type: Any - dots_re = ... # type: Any - magic_re = ... # type: Any - def __init__(self, policy=...) -> None: ... - def set_policy(self, policy): ... - def add_cookie_header(self, request): ... - def make_cookies(self, response, request): ... - def set_cookie_if_ok(self, cookie, request): ... - def set_cookie(self, cookie): ... - def extract_cookies(self, response, request): ... - def clear(self, domain=..., path=..., name=...): ... - def clear_session_cookies(self): ... - def clear_expired_cookies(self): ... - def __iter__(self): ... - def __len__(self): ... +class FileCookieJar(CookieJar): + filename = ... # type: str + delayload = ... # type: bool + def __init__(self, filename: str = ..., delayload: bool = ..., + policy: Optional['CookiePolicy'] = ...) -> None: ... + def save(self, filename: Optional[str] = ..., ignore_discard: bool = ..., + ignore_expires: bool = ...) -> None: ... + def load(self, filename: Optional[str] = ..., ignore_discard: bool = ..., + ignore_expires: bool = ...) -> None: ... + def revert(self, filename: Optional[str] = ..., ignore_discard: bool = ..., + ignore_expires: bool = ...) -> None: ... -class LoadError(OSError): ... +class MozillaCookieJar(FileCookieJar): ... +class LWPCookieJar(FileCookieJar): ... -class FileCookieJar(CookieJar): - filename = ... # type: Any - delayload = ... # type: Any - def __init__(self, filename=..., delayload=..., policy=...) -> None: ... - def save(self, filename=..., ignore_discard=..., ignore_expires=...): ... - def load(self, filename=..., ignore_discard=..., ignore_expires=...): ... - def revert(self, filename=..., ignore_discard=..., ignore_expires=...): ... -class LWPCookieJar(FileCookieJar): - def as_lwp_str(self, ignore_discard=..., ignore_expires=...): ... - def save(self, filename=..., ignore_discard=..., ignore_expires=...): ... +class CookiePolicy: + netscape = ... # type: bool + rfc2965 = ... # type: bool + hide_cookie2 = ... # type: bool + def set_ok(self, cookie: 'Cookie', request: Request) -> bool: ... + def return_ok(self, cookie: 'Cookie', request: Request) -> bool: ... + def domain_return_ok(self, domain: str, request: Request) -> bool: ... + def path_return_ok(self, path: str, request: Request) -> bool: ... + + +class DefaultCookiePolicy(CookiePolicy): + rfc2109_as_netscape = ... # type: bool + strict_domain = ... # type: bool + strict_rfc2965_unverifiable = ... # type: bool + strict_ns_unverifiable = ... # type: bool + strict_ns_domain = ... # type: int + strict_ns_set_initial_dollar = ... # type: bool + strict_ns_set_path = ... # type: bool + DomainStrictNoDots = ... # type: int + DomainStrictNonDomain = ... # type: int + DomainRFC2965Match = ... # type: int + DomainLiberal = ... # type: int + DomainStrict = ... # type: int + def __init__(self, blocked_domains: Optional[Sequence[str]] = ..., + allowed_domains: Optional[Sequence[str]] = ..., + netscape: bool = ..., + rfc2965: bool = ..., + rfc2109_as_netscape: Optional[bool] = ..., + hide_cookie2: bool = ..., strict_domain: bool = ..., + strict_rfc2965_unverifiable: bool =..., + strict_ns_unverifiable: bool = ..., + strict_ns_domain: int = ..., + strict_ns_set_initial_dollar: bool = ..., + strict_ns_set_path: bool = ...) -> None: ... + def blocked_domains(self) -> Tuple[str, ...]: ... + def set_blocked_domains(self, blocked_domains: Sequence[str]) -> None: ... + def is_blocked(self, domain: str) -> bool: ... + def allowed_domains(self) -> Optional[Tuple[str, ...]]: ... + def set_allowed_domains(self, allowed_domains: Optional[Sequence[str]]) \ + -> None: ... + def is_not_allowed(self, domain: str) -> bool: ... + -class MozillaCookieJar(FileCookieJar): - magic_re = ... # type: Any - header = ... # type: Any - def save(self, filename=..., ignore_discard=..., ignore_expires=...): ... +class Cookie: + version = ... # type: Optional[int] + name = ... # type: str + value = ... # type: Optional[str] + port = ... # type: Optional[str] + path = ... # type: str + secure = ... # type: bool + expires = ... # type: Optional[int] + discard = ... # type: bool + comment = ... # type: Optional[str] + comment_url = ... # type: Optional[str] + rfc2109 = ... # type: bool + port_specified = ... # type: bool + domain_specified = ... # type: bool + domain_initial_dot = ... # type: bool + def has_nonstandard_attr(self, name: str) -> bool: ... + @overload + def get_nonstandard_attr(self, name: str) -> Optional[str]: ... + @overload + def get_nonstandard_attr(self, name: str, default: _T = ...) -> Union[str, _T]: ... + def set_nonstandard_attr(self, name: str, value: str) -> None: ... + def is_expired(self, now: int = ...) -> bool: ...