diff --git a/requests_mock/adapter.pyi b/requests_mock/adapter.pyi index da48e2f..8570cd7 100644 --- a/requests_mock/adapter.pyi +++ b/requests_mock/adapter.pyi @@ -1,8 +1,14 @@ # Stubs for requests_mock.adapter +from http.cookiejar import CookieJar +from io import IOBase +from typing import Any, Callable, Dict, List, NewType, Optional, Pattern, Union + from requests.adapters import BaseAdapter +from requests.packages.urllib3.response import HTTPResponse + +from requests_mock.response import _Context from requests_mock import _RequestObjectProxy -from typing import Any, Callable, Dict, List, NewType, Optional, Pattern, Union AnyMatcher = NewType("AnyMatcher", object) @@ -33,11 +39,19 @@ class Adapter(BaseAdapter, _RequestHistoryTracker): method: Union[str, AnyMatcher], url: Union[str, Pattern[str], AnyMatcher], response_list: Optional[List[Dict[str, Any]]] = ..., + *, request_headers: Dict[str, str] = ..., complete_qs: bool = ..., status_code: int = ..., - text: str = ..., - headers: Optional[Dict[str, str]] = ..., + reason: str = ..., + headers: Dict[str, str] = ..., + cookies: Union[CookieJar, Dict[str, str]] = ..., + json: Union[Any, Callable[[_RequestObjectProxy, _Context], Any]] = ..., + text: Union[str, Callable[[_RequestObjectProxy, _Context], str]] = ..., + content: Union[bytes, Callable[[_RequestObjectProxy, _Context], bytes]] = ..., + body: Union[IOBase, Callable[[_RequestObjectProxy, _Context], IOBase]] = ..., + raw: HTTPResponse = ..., + exc: Exception = ..., additional_matcher: Optional[Callable[[_RequestObjectProxy], bool]] = ..., **kwargs: Any ) -> Any: ... diff --git a/requests_mock/mocker.pyi b/requests_mock/mocker.pyi index 12abb56..31f6464 100644 --- a/requests_mock/mocker.pyi +++ b/requests_mock/mocker.pyi @@ -1,9 +1,15 @@ # Stubs for requests_mock.mocker -from requests_mock.adapter import AnyMatcher +from http.cookiejar import CookieJar +from io import IOBase +from typing import Any, Callable, Dict, List, Optional, Pattern, Type, TypeVar, Union + from requests import Response +from requests.packages.urllib3.response import HTTPResponse + +from requests_mock.adapter import AnyMatcher from requests_mock.request import _RequestObjectProxy -from typing import Any, Callable, Dict, List, Optional, Pattern, Type, TypeVar, Union +from requests_mock.response import _Context DELETE: str GET: str @@ -34,11 +40,19 @@ class MockerCore: method: Union[str, AnyMatcher], url: Union[str, Pattern[str], AnyMatcher], response_list: Optional[List[Dict[str, Any]]] = ..., + *, request_headers: Dict[str, str] = ..., complete_qs: bool = ..., status_code: int = ..., - text: str = ..., - headers: Optional[Dict[str, str]] = ..., + reason: str = ..., + headers: Dict[str, str] = ..., + cookies: Union[CookieJar, Dict[str, str]] = ..., + json: Union[Any, Callable[[_RequestObjectProxy, _Context], Any]] = ..., + text: Union[str, Callable[[_RequestObjectProxy, _Context], str]] = ..., + content: Union[bytes, Callable[[_RequestObjectProxy, _Context], bytes]] = ..., + body: Union[IOBase, Callable[[_RequestObjectProxy, _Context], IOBase]] = ..., + raw: HTTPResponse = ..., + exc: Exception = ..., additional_matcher: Optional[Callable[[_RequestObjectProxy], bool]] = ..., **kwargs: Any) -> Response: ... def request( @@ -46,88 +60,152 @@ class MockerCore: method: Union[str, AnyMatcher], url: Union[str, Pattern[str], AnyMatcher], response_list: Optional[List[Dict[str, Any]]] = ..., + *, request_headers: Dict[str, str] = ..., complete_qs: bool = ..., status_code: int = ..., - text: str = ..., - headers: Optional[Dict[str, str]] = ..., + reason: str = ..., + headers: Dict[str, str] = ..., + cookies: Union[CookieJar, Dict[str, str]] = ..., + json: Union[Any, Callable[[_RequestObjectProxy, _Context], Any]] = ..., + text: Union[str, Callable[[_RequestObjectProxy, _Context], str]] = ..., + content: Union[bytes, Callable[[_RequestObjectProxy, _Context], bytes]] = ..., + body: Union[IOBase, Callable[[_RequestObjectProxy, _Context], IOBase]] = ..., + raw: HTTPResponse = ..., + exc: Exception = ..., additional_matcher: Optional[Callable[[_RequestObjectProxy], bool]] = ..., **kwargs: Any) -> Response: ... def get( self, url: Union[str, Pattern[str], AnyMatcher], response_list: Optional[List[Dict[str, Any]]] = ..., + *, request_headers: Dict[str, str] = ..., complete_qs: bool = ..., status_code: int = ..., - text: str = ..., - headers: Optional[Dict[str, str]] = ..., + reason: str = ..., + headers: Dict[str, str] = ..., + cookies: Union[CookieJar, Dict[str, str]] = ..., + json: Union[Any, Callable[[_RequestObjectProxy, _Context], Any]] = ..., + text: Union[str, Callable[[_RequestObjectProxy, _Context], str]] = ..., + content: Union[bytes, Callable[[_RequestObjectProxy, _Context], bytes]] = ..., + body: Union[IOBase, Callable[[_RequestObjectProxy, _Context], IOBase]] = ..., + raw: HTTPResponse = ..., + exc: Exception = ..., additional_matcher: Optional[Callable[[_RequestObjectProxy], bool]] = ..., **kwargs: Any) -> Response: ... def head( self, url: Union[str, Pattern[str], AnyMatcher], response_list: Optional[List[Dict[str, Any]]] = ..., + *, request_headers: Dict[str, str] = ..., complete_qs: bool = ..., status_code: int = ..., - text: str = ..., - headers: Optional[Dict[str, str]] = ..., + reason: str = ..., + headers: Dict[str, str] = ..., + cookies: Union[CookieJar, Dict[str, str]] = ..., + json: Union[Any, Callable[[_RequestObjectProxy, _Context], Any]] = ..., + text: Union[str, Callable[[_RequestObjectProxy, _Context], str]] = ..., + content: Union[bytes, Callable[[_RequestObjectProxy, _Context], bytes]] = ..., + body: Union[IOBase, Callable[[_RequestObjectProxy, _Context], IOBase]] = ..., + raw: HTTPResponse = ..., + exc: Exception = ..., additional_matcher: Optional[Callable[[_RequestObjectProxy], bool]] = ..., **kwargs: Any) -> Response: ... def options( self, url: Union[str, Pattern[str], AnyMatcher], response_list: Optional[List[Dict[str, Any]]] = ..., + *, request_headers: Dict[str, str] = ..., complete_qs: bool = ..., status_code: int = ..., - text: str = ..., - headers: Optional[Dict[str, str]] = ..., + reason: str = ..., + headers: Dict[str, str] = ..., + cookies: Union[CookieJar, Dict[str, str]] = ..., + json: Union[Any, Callable[[_RequestObjectProxy, _Context], Any]] = ..., + text: Union[str, Callable[[_RequestObjectProxy, _Context], str]] = ..., + content: Union[bytes, Callable[[_RequestObjectProxy, _Context], bytes]] = ..., + body: Union[IOBase, Callable[[_RequestObjectProxy, _Context], IOBase]] = ..., + raw: HTTPResponse = ..., + exc: Exception = ..., additional_matcher: Optional[Callable[[_RequestObjectProxy], bool]] = ..., **kwargs: Any) -> Response: ... def post( self, url: Union[str, Pattern[str], AnyMatcher], response_list: Optional[List[Dict[str, Any]]] = ..., + *, request_headers: Dict[str, str] = ..., complete_qs: bool = ..., status_code: int = ..., - text: str = ..., - headers: Optional[Dict[str, str]] = ..., + reason: str = ..., + headers: Dict[str, str] = ..., + cookies: Union[CookieJar, Dict[str, str]] = ..., + json: Union[Any, Callable[[_RequestObjectProxy, _Context], Any]] = ..., + text: Union[str, Callable[[_RequestObjectProxy, _Context], str]] = ..., + content: Union[bytes, Callable[[_RequestObjectProxy, _Context], bytes]] = ..., + body: Union[IOBase, Callable[[_RequestObjectProxy, _Context], IOBase]] = ..., + raw: HTTPResponse = ..., + exc: Exception = ..., additional_matcher: Optional[Callable[[_RequestObjectProxy], bool]] = ..., **kwargs: Any) -> Response: ... def put( self, url: Union[str, Pattern[str], AnyMatcher], response_list: Optional[List[Dict[str, Any]]] = ..., + *, request_headers: Dict[str, str] = ..., complete_qs: bool = ..., status_code: int = ..., - text: str = ..., - headers: Optional[Dict[str, str]] = ..., + reason: str = ..., + headers: Dict[str, str] = ..., + cookies: Union[CookieJar, Dict[str, str]] = ..., + json: Union[Any, Callable[[_RequestObjectProxy, _Context], Any]] = ..., + text: Union[str, Callable[[_RequestObjectProxy, _Context], str]] = ..., + content: Union[bytes, Callable[[_RequestObjectProxy, _Context], bytes]] = ..., + body: Union[IOBase, Callable[[_RequestObjectProxy, _Context], IOBase]] = ..., + raw: HTTPResponse = ..., + exc: Exception = ..., additional_matcher: Optional[Callable[[_RequestObjectProxy], bool]] = ..., **kwargs: Any) -> Response: ... def patch( self, url: Union[str, Pattern[str], AnyMatcher], response_list: Optional[List[Dict[str, Any]]] = ..., + *, request_headers: Dict[str, str] = ..., complete_qs: bool = ..., status_code: int = ..., - text: str = ..., - headers: Optional[Dict[str, str]] = ..., + reason: str = ..., + headers: Dict[str, str] = ..., + cookies: Union[CookieJar, Dict[str, str]] = ..., + json: Union[Any, Callable[[_RequestObjectProxy, _Context], Any]] = ..., + text: Union[str, Callable[[_RequestObjectProxy, _Context], str]] = ..., + content: Union[bytes, Callable[[_RequestObjectProxy, _Context], bytes]] = ..., + body: Union[IOBase, Callable[[_RequestObjectProxy, _Context], IOBase]] = ..., + raw: HTTPResponse = ..., + exc: Exception = ..., additional_matcher: Optional[Callable[[_RequestObjectProxy], bool]] = ..., **kwargs: Any) -> Response: ... def delete( self, url: Union[str, Pattern[str], AnyMatcher], response_list: Optional[List[Dict[str, Any]]] = ..., + *, request_headers: Dict[str, str] = ..., complete_qs: bool = ..., status_code: int = ..., - text: str = ..., - headers: Optional[Dict[str, str]] = ..., + reason: str = ..., + headers: Dict[str, str] = ..., + cookies: Union[CookieJar, Dict[str, str]] = ..., + json: Union[Any, Callable[[_RequestObjectProxy, _Context], Any]] = ..., + text: Union[str, Callable[[_RequestObjectProxy, _Context], str]] = ..., + content: Union[bytes, Callable[[_RequestObjectProxy, _Context], bytes]] = ..., + body: Union[IOBase, Callable[[_RequestObjectProxy, _Context], IOBase]] = ..., + raw: HTTPResponse = ..., + exc: Exception = ..., additional_matcher: Optional[Callable[[_RequestObjectProxy], bool]] = ..., **kwargs: Any) -> Response: ...