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 :
@@ -201,11 +206,13 @@ def _build_request(
201206
202207
203208class TestClient (NinjaClientBase ["NinjaResponse" ]):
209+ @override
204210 def _call (self , func : Callable , request : Mock , kwargs : Dict ) -> "NinjaResponse" :
205211 return NinjaResponse (func (request , ** kwargs ))
206212
207213
208214class TestAsyncClient (NinjaClientBase [Awaitable ["NinjaResponse" ]]):
215+ @override
209216 async def _call (
210217 self , func : Callable , request : Mock , kwargs : Dict
211218 ) -> "NinjaResponse" :
0 commit comments