1
+ from collections .abc import Iterable , Mapping
1
2
from typing import Any
2
3
3
4
import coreapi
@@ -13,6 +14,13 @@ from django.test.client import RequestFactory as DjangoRequestFactory
13
14
from rest_framework .authtoken .models import Token
14
15
from rest_framework .request import Request
15
16
from rest_framework .response import _MonkeyPatchedResponse
17
+ from typing_extensions import TypeAlias
18
+
19
+ _GetDataType : TypeAlias = (
20
+ Mapping [str , str | bytes | int | Iterable [str | bytes | int ]]
21
+ | Iterable [tuple [str , str | bytes | int | Iterable [str | bytes | int ]]]
22
+ | None
23
+ )
16
24
17
25
def force_authenticate (
18
26
request : HttpRequest , user : AnonymousUser | AbstractBaseUser | None = ..., token : Token | None = ...
@@ -50,7 +58,7 @@ class APIRequestFactory(DjangoRequestFactory):
50
58
renderer_classes : Any
51
59
def __init__ (self , enforce_csrf_checks : bool = ..., ** defaults : Any ) -> None : ...
52
60
def request (self , ** kwargs : Any ) -> Request : ... # type: ignore[override]
53
- def get (self , path : str , data : dict [ str , Any ] | str | None = ..., follow : bool = ..., ** extra : Any ) -> Request : ... # type: ignore[override]
61
+ def get (self , path : str , data : _GetDataType = ..., follow : bool = ..., ** extra : Any ) -> Request : ... # type: ignore[override]
54
62
def post (self , path : str , data : Any | None = ..., format : str | None = ..., content_type : str | None = ..., follow : bool = ..., ** extra : Any ) -> Request : ... # type: ignore[override]
55
63
def put (self , path : str , data : Any | None = ..., format : str | None = ..., content_type : str | None = ..., follow : bool = ..., ** extra : Any ) -> Request : ... # type: ignore[override]
56
64
def patch (self , path : str , data : Any | None = ..., format : str | None = ..., content_type : str | None = ..., follow : bool = ..., ** extra : Any ) -> Request : ... # type: ignore[override]
@@ -68,7 +76,7 @@ class APIClient(APIRequestFactory, DjangoClient):
68
76
def credentials (self , ** kwargs : Any ): ...
69
77
def force_authenticate (self , user : AnonymousUser | AbstractBaseUser = ..., token : Token | None = ...) -> None : ...
70
78
def request (self , ** kwargs : Any ) -> _MonkeyPatchedResponse : ... # type: ignore[override]
71
- def get (self , path : str , data : dict [ str , Any ] | str | None = ..., follow : bool = ..., ** extra : Any ) -> _MonkeyPatchedResponse : ... # type: ignore[override]
79
+ def get (self , path : str , data : _GetDataType = ..., follow : bool = ..., ** extra : Any ) -> _MonkeyPatchedResponse : ... # type: ignore[override]
72
80
def post (self , path : str , data : Any | None = ..., format : str | None = ..., content_type : str | None = ..., follow : bool = ..., ** extra : Any ) -> _MonkeyPatchedResponse : ... # type: ignore[override]
73
81
def put (self , path : str , data : Any | None = ..., format : str | None = ..., content_type : str | None = ..., follow : bool = ..., ** extra : Any ) -> _MonkeyPatchedResponse : ... # type: ignore[override]
74
82
def patch (self , path : str , data : Any | None = ..., format : str | None = ..., content_type : str | None = ..., follow : bool = ..., ** extra : Any ) -> _MonkeyPatchedResponse : ... # type: ignore[override]
0 commit comments