Mark requests stubs as complete (#8858)

Co-authored-by: Kevin Kirsche <kevin.kirsche@one.verizon.com>
This commit is contained in:
Alex Waygood
2022-10-06 15:31:02 -07:00
committed by GitHub
parent 9da105d4d9
commit e173cbe7b6
7 changed files with 79 additions and 10 deletions

View File

@@ -1,6 +1,40 @@
# Re-exports from urllib3 (should be fixed in those stubs, not here)
requests.adapters.HTTPResponse.DECODER_ERROR_CLASSES
requests.adapters.PoolManager.connection_from_context
requests.adapters.PoolManager.connection_from_host
requests.adapters.PoolManager.connection_from_pool_key
requests.adapters.PoolManager.connection_from_url
requests.adapters.PoolManager.proxy_config
requests.adapters.PoolManager.urlopen
requests.sessions.SessionRedirectMixin.resolve_redirects
requests.structures.LookupDict.__getattr__
requests.structures.LookupDict.get
requests.adapters.Retry.DEFAULT
# Unnecessary re-exported constants from requests.compat
requests.adapters.basestring
requests.auth.basestring
requests.utils.basestring
requests.utils.integer_types
requests.models.basestring
# Unnecessary re-exported constant
# (you should access this as `requests.__version__` or `requests.__version__.__version__`,
# not `requests.help.requests_version`)
requests.help.requests_version
# No reason to access this re-exported constant from `requests.sessions` instead of from `requests.utils`
requests.sessions.DEFAULT_PORTS
# Unnecessary re-exports of third-party modules
requests.help.chardet
requests.help.cryptography
requests.help.pyopenssl
requests.help.OpenSSL
# Loop variables that leak into the global scope
requests.packages.mod
requests.packages.package
requests.packages.target
# Internal implementation details, not for public consumption
requests.charset_normalizer_version
requests.chardet_version
requests.utils.HEADER_VALIDATORS

View File

@@ -2,4 +2,5 @@ version = "2.28.*"
requires = ["types-urllib3<1.27"] # keep in sync with requests's setup.py
[tool.stubtest]
ignore_missing_stub = false
extras = ["socks"]

View File

@@ -0,0 +1 @@
# no public data

View File

@@ -1,4 +1,6 @@
from builtins import bytes as bytes, str as str
from collections import OrderedDict as OrderedDict
from typing_extensions import TypeAlias
from urllib.parse import (
quote as quote,
quote_plus as quote_plus,
@@ -16,3 +18,8 @@ from urllib.request import getproxies as getproxies, parse_http_list as parse_ht
is_py2: bool
is_py3: bool
has_simplejson: bool
builtin_str: TypeAlias = str # noqa: Y042
basestring: tuple[type, ...]
numeric_types: tuple[type, ...]
integer_types: tuple[type, ...]

View File

@@ -1,4 +1,4 @@
from _typeshed import Self, SupportsItems, SupportsRead
from _typeshed import Incomplete, Self, SupportsItems, SupportsRead
from collections.abc import Callable, Iterable, Mapping, MutableMapping
from typing import Any, Union
from typing_extensions import TypeAlias, TypedDict
@@ -40,10 +40,23 @@ def merge_setting(request_setting, session_setting, dict_class=...): ...
def merge_hooks(request_hooks, session_hooks, dict_class=...): ...
class SessionRedirectMixin:
def resolve_redirects(self, resp, req, stream=..., timeout=..., verify=..., cert=..., proxies=...): ...
def resolve_redirects(
self,
resp,
req,
stream: bool = ...,
timeout: Incomplete | None = ...,
verify: bool = ...,
cert: Incomplete | None = ...,
proxies: Incomplete | None = ...,
yield_requests: bool = ...,
**adapter_kwargs,
): ...
def rebuild_auth(self, prepared_request, response): ...
def rebuild_proxies(self, prepared_request, proxies): ...
def should_strip_auth(self, old_url, new_url): ...
def rebuild_method(self, prepared_request: PreparedRequest, response: Response) -> None: ...
def get_redirect_target(self, resp: Response) -> str | None: ...
_Data: TypeAlias = (
# used in requests.models.PreparedRequest.prepare_body

View File

@@ -1,6 +1,7 @@
from collections.abc import Iterable, Iterator, Mapping, MutableMapping
from typing import Any, Generic, TypeVar
from typing import Any, Generic, TypeVar, overload
_D = TypeVar("_D")
_VT = TypeVar("_VT")
class CaseInsensitiveDict(MutableMapping[str, _VT], Generic[_VT]):
@@ -17,5 +18,8 @@ class LookupDict(dict[str, _VT]):
name: Any
def __init__(self, name: Any = ...) -> None: ...
def __getitem__(self, key: str) -> _VT | None: ... # type: ignore[override]
def __getattr__(self, attr: str) -> _VT: ...
def __setattr__(self, __attr: str, __value: _VT) -> None: ...
@overload
def get(self, key: str, default: None = ...) -> _VT | None: ...
@overload
def get(self, key: str, default: _D | _VT) -> _D | _VT: ...

View File

@@ -1,10 +1,13 @@
import sys
from _typeshed import StrOrBytesPath
from collections.abc import Generator, Iterable, Mapping
from contextlib import AbstractContextManager
from contextlib import _GeneratorContextManager
from io import BufferedWriter
from typing import Any, AnyStr
from typing_extensions import TypeAlias
from . import compat, cookies, exceptions, structures
from .models import PreparedRequest
from .models import PreparedRequest, Request
_Uri: TypeAlias = str | bytes
OrderedDict = compat.OrderedDict
@@ -22,6 +25,7 @@ def super_len(o): ...
def get_netrc_auth(url: _Uri, raise_errors: bool = ...) -> tuple[str, str] | None: ...
def guess_filename(obj): ...
def extract_zipped_paths(path): ...
def atomic_open(filename: StrOrBytesPath) -> _GeneratorContextManager[BufferedWriter]: ...
def from_key_val_list(value): ...
def to_key_val_list(value): ...
def parse_list_header(value): ...
@@ -43,10 +47,11 @@ def address_in_network(ip: str, net: str) -> bool: ...
def dotted_netmask(mask: int) -> str: ...
def is_ipv4_address(string_ip: str) -> bool: ...
def is_valid_cidr(string_network: str) -> bool: ...
def set_environ(env_name: str, value: None) -> AbstractContextManager[None]: ...
def set_environ(env_name: str, value: None) -> _GeneratorContextManager[None]: ...
def should_bypass_proxies(url: _Uri, no_proxy: Iterable[str] | None) -> bool: ...
def get_environ_proxies(url: _Uri, no_proxy: Iterable[str] | None = ...) -> dict[Any, Any]: ...
def select_proxy(url: _Uri, proxies: Mapping[Any, Any] | None): ...
def resolve_proxies(request: Request | PreparedRequest, proxies: Mapping[str, str] | None, trust_env: bool = ...): ...
def default_user_agent(name: str = ...) -> str: ...
def default_headers() -> CaseInsensitiveDict[str]: ...
def parse_header_links(value: str) -> list[dict[str, str]]: ...
@@ -57,3 +62,7 @@ def to_native_string(string, encoding=...): ...
def urldefragauth(url: _Uri): ...
def rewind_body(prepared_request: PreparedRequest) -> None: ...
def check_header_validity(header: tuple[AnyStr, AnyStr]) -> None: ...
if sys.platform == "win32":
def proxy_bypass_registry(host: str) -> bool: ...
def proxy_bypass(host: str) -> bool: ...