Skip to content

Commit

Permalink
Improve type definition of Mocker.__call__
Browse files Browse the repository at this point in the history
  • Loading branch information
Viicos committed Jan 22, 2024
1 parent c06f124 commit 51d0a73
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions requests_mock/mocker.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from json import JSONEncoder
from http.cookiejar import CookieJar
from io import IOBase
from typing import Any, Callable, Dict, List, Optional, Pattern, Type, TypeVar, Union
from typing import Any, Callable, Dict, List, Optional, Pattern, Type, TypeVar, Union, overload

from requests import Response, Session
from urllib3.response import HTTPResponse
Expand Down Expand Up @@ -239,6 +239,7 @@ class MockerCore:
) -> _Matcher: ...

_T = TypeVar('_T')
_CallableT = TypeVar("_CallableT", bound=Callable)

class Mocker(MockerCore):
TEST_PREFIX: str = ...
Expand All @@ -255,9 +256,12 @@ class Mocker(MockerCore):
) -> None: ...
def __enter__(self) -> Any: ...
def __exit__(self, type: Any, value: Any, traceback: Any) -> None: ...
def __call__(self, obj: Any) -> Any: ...
@overload
def __call__(self, obj: type[_T]) -> type[_T]: ...
@overload
def __call__(self, obj: _CallableT) -> _CallableT: ...
def copy(self) -> Mocker: ...
def decorate_callable(self, func: Callable[..., _T]) -> Callable[..., _T]: ...
def decorate_callable(self, func: _CallableT) -> _CallableT: ...
def decorate_class(self, klass: Type[_T]) -> Type[_T]: ...

mock = Mocker

0 comments on commit 51d0a73

Please sign in to comment.