1+ from abc import ABC , abstractmethod
12from json import dumps as json_dumps
23from json import loads as json_loads
34from typing import (
1213 TypeVar ,
1314 Union ,
1415 cast ,
16+ override ,
1517)
1618from unittest .mock import Mock
1719from urllib .parse import urljoin
@@ -37,7 +39,7 @@ def build_absolute_uri(location: Optional[str] = None) -> str:
3739
3840# TODO: this should be changed
3941# maybe add here urlconf object and add urls from here
40- class NinjaClientBase (Generic [ResponseT ]):
42+ class NinjaClientBase (Generic [ResponseT ], ABC ):
4143 __test__ = False # <- skip pytest
4244
4345 def __init__ (
@@ -114,7 +116,10 @@ def request(
114116 ** request_params .get ("COOKIES" , {}),
115117 }
116118 func , request , kwargs = self ._resolve (method , path , data , request_params )
117- return self ._call (func , request , kwargs ) # type: ignore
119+ return self ._call (func , request , kwargs )
120+
121+ @abstractmethod
122+ def _call (self , func : Callable , request : Mock , kwargs : Dict ) -> ResponseT : ...
118123
119124 @property
120125 def urls (self ) -> List :
@@ -203,11 +208,13 @@ def _build_request(
203208
204209
205210class TestClient (NinjaClientBase ["NinjaResponse" ]):
211+ @override
206212 def _call (self , func : Callable , request : Mock , kwargs : Dict ) -> "NinjaResponse" :
207213 return NinjaResponse (func (request , ** kwargs ))
208214
209215
210216class TestAsyncClient (NinjaClientBase [Awaitable ["NinjaResponse" ]]):
217+ @override
211218 async def _call (
212219 self , func : Callable , request : Mock , kwargs : Dict
213220 ) -> "NinjaResponse" :
0 commit comments