From 6178ed3201b94f5cc0540cc57cd069b99858a5cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adam=20Marsza=C5=82ek?= Date: Fri, 20 Jan 2017 18:09:23 +0100 Subject: [PATCH] Expansion of unions inside `params` definition (#848) Due to `Dict` / `Mapping` invariance it's necessary to include other variants of `Union[str, bytes], Union[str, bytes]`. --- third_party/2/requests/api.pyi | 14 +++++++++----- third_party/3/requests/api.pyi | 12 +++++++++--- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/third_party/2/requests/api.pyi b/third_party/2/requests/api.pyi index 6472b6973..9f041d21c 100644 --- a/third_party/2/requests/api.pyi +++ b/third_party/2/requests/api.pyi @@ -1,18 +1,22 @@ # Stubs for requests.api (Python 2) -from typing import Union, Optional, Iterable, Dict, Tuple +from typing import Union, Optional, Iterable, Mapping, Tuple from .models import Response -def request(method: str, url: str, **kwargs) -> Response: ... +ParamsMappingValueType = Union[str, unicode, int, float, Iterable[Union[str, unicode, int, float]]] +def request(method: str, url: str, **kwargs) -> Response: ... def get(url: Union[str, unicode], params: Optional[ - Union[Dict[Union[str, unicode, int, float], Union[str, unicode, int, float, Iterable[Union[str, unicode, int, float]]]], + Union[Mapping[Union[str, unicode, int, float], ParamsMappingValueType], Union[str, unicode], - Tuple[Union[str, unicode, int, float], Union[str, unicode, int, float, Iterable[Union[str, unicode, int, float]]]]]] = None, + Tuple[Union[str, unicode, int, float], ParamsMappingValueType], + Mapping[str, ParamsMappingValueType], + Mapping[unicode, ParamsMappingValueType], + Mapping[int, ParamsMappingValueType], + Mapping[float, ParamsMappingValueType]]] = None, **kwargs) -> Response: ... - def options(url: Union[str, unicode], **kwargs) -> Response: ... def head(url: Union[str, unicode], **kwargs) -> Response: ... def post(url: Union[str, unicode], data=..., json=..., diff --git a/third_party/3/requests/api.pyi b/third_party/3/requests/api.pyi index 90bf70256..120f695c4 100644 --- a/third_party/3/requests/api.pyi +++ b/third_party/3/requests/api.pyi @@ -1,16 +1,22 @@ # Stubs for requests.api (Python 3) -from typing import Optional, Union, Any, Iterable, Dict, Tuple +from typing import Optional, Union, Any, Iterable, Mapping, Tuple from .models import Response +ParamsMappingValueType = Union[str, bytes, int, float, Iterable[Union[str, bytes, int, float]]] + def request(method: str, url: str, **kwargs) -> Response: ... def get(url: Union[str, bytes], params: Optional[ Union[ - Dict[Union[str, bytes, int, float], Union[str, bytes, int, float, Iterable[Union[str, bytes, int, float]]]], + Mapping[Union[str, bytes, int, float], ParamsMappingValueType], Union[str, bytes], - Tuple[Union[str, bytes, int, float], Union[str, bytes, int, float, Iterable[Union[str, bytes, int, float]]]]]] = None, + Tuple[Union[str, bytes, int, float], ParamsMappingValueType], + Mapping[str, ParamsMappingValueType], + Mapping[bytes, ParamsMappingValueType], + Mapping[int, ParamsMappingValueType], + Mapping[float, ParamsMappingValueType]]]=None, **kwargs) -> Response: ... def options(url: str, **kwargs) -> Response: ... def head(url: str, **kwargs) -> Response: ...