Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve type definition of Mocker.__call__ #244

Merged
merged 1 commit into from
Jan 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading