Skip to content

Commit 94f20de

Browse files
committed
Improve MockerCore type stubs
For #171 Modifications to `MockerCore`: - Adds the missing `url` parameter to the `register_uri` and `request` methods. - Renames the `path` parameters of `delete`, `get`, `head`, `options`, `patch`, `post`, and `put` methods to `url` to match the name of the corresponding parameter in `requests_mock.adapter.Adapter.register_uri`. - Changes the types of various `method` and `url` parameters to support the `requests_mock.adapter.ANY` "wildcard" value.
1 parent 850671f commit 94f20de

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

requests_mock/mocker.pyi

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,71 +30,73 @@ class MockerCore:
3030
def call_count(self) -> int: ...
3131
def register_uri(
3232
self,
33-
method: str,
33+
method: Union[str, Any],
34+
url: Union[str, Pattern[str], Any],
3435
status_code: int = ...,
3536
text: str = ...,
3637
headers: Optional[Dict[str, str]] = ...,
3738
additional_matcher: Optional[Callable[[_RequestObjectProxy], bool]] = ...,
3839
**kwargs: Any) -> Response: ...
3940
def request(
4041
self,
41-
method: str,
42+
method: Union[str, Any],
43+
url: Union[str, Pattern[str], Any],
4244
status_code: int = ...,
4345
text: str = ...,
4446
headers: Optional[Dict[str, str]] = ...,
4547
additional_matcher: Optional[Callable[[_RequestObjectProxy], bool]] = ...,
4648
**kwargs: Any) -> Response: ...
4749
def get(
4850
self,
49-
path: Union[str, Pattern[str]],
51+
url: Union[str, Pattern[str], Any],
5052
status_code: int = ...,
5153
text: str = ...,
5254
headers: Optional[Dict[str, str]] = ...,
5355
additional_matcher: Optional[Callable[[_RequestObjectProxy], bool]] = ...,
5456
**kwargs: Any) -> Response: ...
5557
def head(
5658
self,
57-
path: Union[str, Pattern[str]],
59+
url: Union[str, Pattern[str], Any],
5860
status_code: int = ...,
5961
text: str = ...,
6062
headers: Optional[Dict[str, str]] = ...,
6163
additional_matcher: Optional[Callable[[_RequestObjectProxy], bool]] = ...,
6264
**kwargs: Any) -> Response: ...
6365
def options(
6466
self,
65-
path: Union[str, Pattern[str]],
67+
url: Union[str, Pattern[str], Any],
6668
status_code: int = ...,
6769
text: str = ...,
6870
headers: Optional[Dict[str, str]] = ...,
6971
additional_matcher: Optional[Callable[[_RequestObjectProxy], bool]] = ...,
7072
**kwargs: Any) -> Response: ...
7173
def post(
7274
self,
73-
path: Union[str, Pattern[str]],
75+
url: Union[str, Pattern[str], Any],
7476
status_code: int = ...,
7577
text: str = ...,
7678
headers: Optional[Dict[str, str]] = ...,
7779
additional_matcher: Optional[Callable[[_RequestObjectProxy], bool]] = ...,
7880
**kwargs: Any) -> Response: ...
7981
def put(
8082
self,
81-
path: Union[str, Pattern[str]],
83+
url: Union[str, Pattern[str], Any],
8284
status_code: int = ...,
8385
text: str = ...,
8486
headers: Optional[Dict[str, str]] = ...,
8587
additional_matcher: Optional[Callable[[_RequestObjectProxy], bool]] = ...,
8688
**kwargs: Any) -> Response: ...
8789
def patch(
8890
self,
89-
path: Union[str, Pattern[str]],
91+
url: Union[str, Pattern[str], Any],
9092
status_code: int = ...,
9193
text: str = ...,
9294
headers: Optional[Dict[str, str]] = ...,
9395
additional_matcher: Optional[Callable[[_RequestObjectProxy], bool]] = ...,
9496
**kwargs: Any) -> Response: ...
9597
def delete(
9698
self,
97-
path: Union[str, Pattern[str]],
99+
url: Union[str, Pattern[str], Any],
98100
status_code: int = ...,
99101
text: str = ...,
100102
headers: Optional[Dict[str, str]] = ...,

0 commit comments

Comments
 (0)