From c1cb9080495a583577fd54a3ec0c5c9425f4aa71 Mon Sep 17 00:00:00 2001 From: JWM <62558419+JokeWaumans@users.noreply.github.com> Date: Mon, 5 Aug 2024 09:25:30 +0200 Subject: [PATCH] Use `response` instead of `req`; remove indentation after return Co-authored-by: Jasper Craeghs <28319872+JasperCraeghs@users.noreply.github.com> --- mlx/coverity_services.py | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/mlx/coverity_services.py b/mlx/coverity_services.py index 18d9b124..9cf139db 100644 --- a/mlx/coverity_services.py +++ b/mlx/coverity_services.py @@ -161,17 +161,16 @@ def _get_request(self, url): Raises: requests.HTTPError """ - req = self.session.get(url) - if req.ok: - return json.loads(req.content) - else: - try: - message = json.loads(req.content)["message"] - except: - message = req.content.decode() - logger = getLogger("coverity_logging") - logger.warning(message) - return req.raise_for_status() + response= self.session.get(url) + if response.ok: + return response.json() + try: + err_msg= response.json()["message"] + except (requests.exceptions.JSONDecodeError, KeyError): + err_msg= response.content.decode() + logger = getLogger("coverity_logging") + logger.warning(err_msg) + return response.raise_for_status() def _post_request(self, url, data): """Perform a POST request to the specified url.