From 6c2468ab312a5f2ccbccedb9f2cca351e79622c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Mon, 8 Sep 2025 22:15:27 +0300 Subject: [PATCH 1/2] Avoid duplicate calls to e.response.json() --- trakt/api.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/trakt/api.py b/trakt/api.py index 3c09cab..7d6160a 100644 --- a/trakt/api.py +++ b/trakt/api.py @@ -256,8 +256,9 @@ def refresh_token(self): except (OAuthException, BadRequestException) as e: if e.response is not None: try: - error = e.response.json().get("error") - error_description = e.response.json().get("error_description") + data = e.response.json() + error = data.get("error") + error_description = data.get("error_description") except JSONDecodeError: error = "Invalid JSON response" error_description = e.response.text From 777f45db494db048f58cbd1b99bcae8d15f69f82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elan=20Ruusam=C3=A4e?= Date: Mon, 8 Sep 2025 22:15:39 +0300 Subject: [PATCH 2/2] Auto-format api.py imports --- trakt/api.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/trakt/api.py b/trakt/api.py index 7d6160a..6ce7960 100644 --- a/trakt/api.py +++ b/trakt/api.py @@ -10,7 +10,8 @@ from trakt import errors from trakt.config import AuthConfig from trakt.core import TIMEOUT -from trakt.errors import BadRequestException, BadResponseException, OAuthException +from trakt.errors import (BadRequestException, BadResponseException, + OAuthException) __author__ = 'Elan Ruusamäe'