From 13857cf29ae29265ef5d6445436a09dd14eabe33 Mon Sep 17 00:00:00 2001 From: Flavio Garcia Date: Thu, 20 Jun 2024 22:59:59 -0400 Subject: [PATCH] fix(transport): set update_kwargs return to the original kwargs Fixes: #16 --- peasant/client/transport_requests.py | 19 +++++++------------ peasant/client/transport_tornado.py | 7 +++++++ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/peasant/client/transport_requests.py b/peasant/client/transport_requests.py index 471bb84..2cc5474 100644 --- a/peasant/client/transport_requests.py +++ b/peasant/client/transport_requests.py @@ -60,11 +60,6 @@ def get_headers(self, **kwargs): headers.update(_headers) return headers - def update_kwargs(self, method, **kwargs): - if self.kwargs_updater is None: - return kwargs - return self.kwargs_updater(method, **kwargs) - def delete(self, path: str, **kwargs): """ Sends a delete method with basic headers. @@ -74,7 +69,7 @@ def delete(self, path: str, **kwargs): :return: :class:`requests.Response ` object :rtype: requests.Response """ - self.update_kwargs("DELETE", **kwargs) + kwargs = self.update_kwargs("DELETE", **kwargs) url = self.get_url(path, **kwargs) headers = self.get_headers(**kwargs) kwargs['headers'] = headers @@ -91,7 +86,7 @@ def get(self, path, **kwargs): :return: :class:`requests.Response ` object :rtype: requests.Response """ - self.update_kwargs(METHOD_GET, **kwargs) + kwargs = self.update_kwargs(METHOD_GET, **kwargs) url = self.get_url(path, **kwargs) headers = self.get_headers(**kwargs) kwargs['headers'] = headers @@ -108,7 +103,7 @@ def head(self, path, **kwargs): :return: :class:`requests.Response ` object :rtype: requests.Response """ - self.update_kwargs(METHOD_HEAD, **kwargs) + kwargs = self.update_kwargs(METHOD_HEAD, **kwargs) url = self.get_url(path, **kwargs) headers = self.get_headers(**kwargs) kwargs['headers'] = headers @@ -125,7 +120,7 @@ def options(self, path, **kwargs): :return: :class:`requests.Response ` object :rtype: requests.Response """ - self.update_kwargs(METHOD_OPTIONS, **kwargs) + kwargs = self.update_kwargs(METHOD_OPTIONS, **kwargs) url = self.get_url(path, **kwargs) headers = self.get_headers(**kwargs) kwargs['headers'] = headers @@ -142,7 +137,7 @@ def patch(self, path, **kwargs): :return: :class:`requests.Response ` object :rtype: requests.Response """ - self.update_kwargs(METHOD_PATCH, **kwargs) + kwargs = self.update_kwargs(METHOD_PATCH, **kwargs) url = self.get_url(path, **kwargs) headers = self.get_headers(**kwargs) kwargs['headers'] = headers @@ -159,7 +154,7 @@ def post(self, path, **kwargs): :return: :class:`requests.Response ` object :rtype: requests.Response """ - self.update_kwargs(METHOD_POST, **kwargs) + kwargs = self.update_kwargs(METHOD_POST, **kwargs) url = self.get_url(path, **kwargs) headers = self.get_headers(**kwargs) kwargs['headers'] = headers @@ -176,7 +171,7 @@ def put(self, path, **kwargs): :return: :class:`requests.Response ` object :rtype: requests.Response """ - self.update_kwargs(METHOD_PUT, **kwargs) + kwargs = self.update_kwargs(METHOD_PUT, **kwargs) url = self.get_url(path, **kwargs) headers = self.get_headers(**kwargs) kwargs['headers'] = headers diff --git a/peasant/client/transport_tornado.py b/peasant/client/transport_tornado.py index c684cee..4115893 100644 --- a/peasant/client/transport_tornado.py +++ b/peasant/client/transport_tornado.py @@ -140,6 +140,7 @@ def get_headers(self, **kwargs): return headers async def delete(self, path: str, **kwargs: dict): + kwargs = self.update_kwargs(METHOD_DELETE, **kwargs) url = self.get_url(path, **kwargs) kwargs["method"] = METHOD_DELETE request = get_tornado_request(url, **kwargs) @@ -148,6 +149,7 @@ async def delete(self, path: str, **kwargs: dict): return await self._client.fetch(request) async def get(self, path: str, **kwargs: dict): + kwargs = self.update_kwargs(METHOD_GET, **kwargs) url = self.get_url(path, **kwargs) request = get_tornado_request(url, **kwargs) headers = self.get_headers(**kwargs) @@ -155,6 +157,7 @@ async def get(self, path: str, **kwargs: dict): return await self._client.fetch(request) async def head(self, path: str, **kwargs: dict): + kwargs = self.update_kwargs(METHOD_HEAD, **kwargs) url = self.get_url(path, **kwargs) kwargs["method"] = METHOD_HEAD request = get_tornado_request(url, **kwargs) @@ -163,6 +166,7 @@ async def head(self, path: str, **kwargs: dict): return await self._client.fetch(request) async def options(self, path: str, **kwargs: dict): + kwargs = self.update_kwargs(METHOD_OPTIONS, **kwargs) url = self.get_url(path, **kwargs) kwargs["method"] = METHOD_OPTIONS request = get_tornado_request(url, **kwargs) @@ -171,6 +175,7 @@ async def options(self, path: str, **kwargs: dict): return await self._client.fetch(request) async def patch(self, path: str, **kwargs: dict): + kwargs = self.update_kwargs(METHOD_PATCH, **kwargs) url = self.get_url(path, **kwargs) kwargs["method"] = METHOD_PATCH request = get_tornado_request(url, **kwargs) @@ -179,6 +184,7 @@ async def patch(self, path: str, **kwargs: dict): return await self._client.fetch(request) async def post(self, path: str, **kwargs: dict): + kwargs = self.update_kwargs(METHOD_POST, **kwargs) url = self.get_url(path, **kwargs) kwargs["method"] = METHOD_POST request = get_tornado_request(url, **kwargs) @@ -187,6 +193,7 @@ async def post(self, path: str, **kwargs: dict): return await self._client.fetch(request) async def put(self, path: str, **kwargs: dict): + kwargs = self.update_kwargs(METHOD_PUT, **kwargs) url = self.get_url(path, **kwargs) kwargs["method"] = METHOD_PUT request = get_tornado_request(url, **kwargs)