From 71e2cdcc68d30cc1bbbf7e385e25e5e93809358a Mon Sep 17 00:00:00 2001 From: Vincent Barbaresi Date: Sat, 24 Oct 2020 14:01:24 +0200 Subject: [PATCH] update requests stubs with various missing methods (#4691) --- third_party/2and3/requests/__init__.pyi | 4 +++- third_party/2and3/requests/auth.pyi | 2 +- third_party/2and3/requests/cookies.pyi | 1 + third_party/2and3/requests/models.pyi | 3 +-- third_party/2and3/requests/sessions.pyi | 2 -- third_party/2and3/requests/utils.pyi | 11 ++++++----- 6 files changed, 12 insertions(+), 11 deletions(-) diff --git a/third_party/2and3/requests/__init__.pyi b/third_party/2and3/requests/__init__.pyi index 6f72f86ba..622ffd24f 100644 --- a/third_party/2and3/requests/__init__.pyi +++ b/third_party/2and3/requests/__init__.pyi @@ -1,5 +1,5 @@ import logging -from typing import Any +from typing import Any, Text from .api import ( delete as delete, @@ -31,3 +31,5 @@ __version__: Any class NullHandler(logging.Handler): def emit(self, record): ... + +def check_compatibility(urllib3_version: Text, chardet_version: Text) -> None: ... diff --git a/third_party/2and3/requests/auth.pyi b/third_party/2and3/requests/auth.pyi index b3c3fd7d0..7a9def074 100644 --- a/third_party/2and3/requests/auth.pyi +++ b/third_party/2and3/requests/auth.pyi @@ -5,7 +5,6 @@ from . import cookies, models, status_codes, utils extract_cookies_to_jar = cookies.extract_cookies_to_jar parse_dict_header = utils.parse_dict_header to_native_string = utils.to_native_string -codes = status_codes.codes CONTENT_TYPE_FORM_URLENCODED: Any CONTENT_TYPE_MULTI_PART: Any @@ -37,3 +36,4 @@ class HTTPDigestAuth(AuthBase): def handle_redirect(self, r, **kwargs): ... def handle_401(self, r, **kwargs): ... def __call__(self, r): ... + def init_per_thread_state(self) -> None: ... diff --git a/third_party/2and3/requests/cookies.pyi b/third_party/2and3/requests/cookies.pyi index 559c9e7a5..c53d3f61f 100644 --- a/third_party/2and3/requests/cookies.pyi +++ b/third_party/2and3/requests/cookies.pyi @@ -56,6 +56,7 @@ class RequestsCookieJar(CookieJar, MutableMapping[Any, Any]): def set_cookie(self, cookie, *args, **kwargs): ... def update(self, other): ... def copy(self): ... + def get_policy(self): ... def create_cookie(name, value, **kwargs): ... def morsel_to_cookie(morsel): ... diff --git a/third_party/2and3/requests/models.pyi b/third_party/2and3/requests/models.pyi index 7f2cfac71..c47fa0fc9 100644 --- a/third_party/2and3/requests/models.pyi +++ b/third_party/2and3/requests/models.pyi @@ -40,7 +40,6 @@ REDIRECT_STATI: Any DEFAULT_REDIRECT_LIMIT: Any CONTENT_CHUNK_SIZE: Any ITER_CHUNK_SIZE: Any -json_dumps: Any class RequestEncodingMixin: @property @@ -117,7 +116,7 @@ class Response: def apparent_encoding(self) -> str: ... def iter_content(self, chunk_size: Optional[int] = ..., decode_unicode: bool = ...) -> Iterator[Any]: ... def iter_lines( - self, chunk_size: Optional[int] = ..., decode_unicode: bool = ..., delimiter: Union[Text, bytes] = ... + self, chunk_size: Optional[int] = ..., decode_unicode: bool = ..., delimiter: Optional[Union[Text, bytes]] = ... ) -> Iterator[Any]: ... @property def content(self) -> bytes: ... diff --git a/third_party/2and3/requests/sessions.pyi b/third_party/2and3/requests/sessions.pyi index 3278fd782..700b711ed 100644 --- a/third_party/2and3/requests/sessions.pyi +++ b/third_party/2and3/requests/sessions.pyi @@ -33,8 +33,6 @@ get_auth_from_url = utils.get_auth_from_url codes = status_codes.codes REDIRECT_STATI = models.REDIRECT_STATI -REDIRECT_CACHE_SIZE: Any - def merge_setting(request_setting, session_setting, dict_class=...): ... def merge_hooks(request_hooks, session_hooks, dict_class=...): ... diff --git a/third_party/2and3/requests/utils.pyi b/third_party/2and3/requests/utils.pyi index 4c63bb733..3a84c6254 100644 --- a/third_party/2and3/requests/utils.pyi +++ b/third_party/2and3/requests/utils.pyi @@ -1,4 +1,4 @@ -from typing import Any +from typing import Any, AnyStr, Dict, Iterable, Mapping, Optional, Text, Tuple from . import compat, cookies, exceptions, structures @@ -14,7 +14,7 @@ DEFAULT_PORTS: Any def dict_to_sequence(d): ... def super_len(o): ... -def get_netrc_auth(url): ... +def get_netrc_auth(url, raise_errors: bool = ...): ... def guess_filename(obj): ... def extract_zipped_paths(path): ... def from_key_val_list(value): ... @@ -39,9 +39,9 @@ def dotted_netmask(mask): ... def is_ipv4_address(string_ip): ... def is_valid_cidr(string_network): ... def set_environ(env_name, value): ... -def should_bypass_proxies(url): ... -def get_environ_proxies(url): ... -def select_proxy(url, proxies): ... +def should_bypass_proxies(url, no_proxy: Optional[Iterable[AnyStr]]) -> bool: ... +def get_environ_proxies(url, no_proxy: Optional[Iterable[AnyStr]] = ...) -> Dict[Any, Any]: ... +def select_proxy(url: Text, proxies: Optional[Mapping[Any, Any]]): ... def default_user_agent(name=...): ... def default_headers(): ... def parse_header_links(value): ... @@ -51,3 +51,4 @@ def get_auth_from_url(url): ... def to_native_string(string, encoding=...): ... def urldefragauth(url): ... def rewind_body(prepared_request): ... +def check_header_validity(header: Tuple[AnyStr, AnyStr]) -> None: ...