From d2c26fcbe10361f1ba19f91d77023a1d1669bcfe Mon Sep 17 00:00:00 2001 From: Daniel Herrmann Date: Tue, 20 Aug 2024 19:41:06 +0200 Subject: [PATCH] fix: mypy type error on refresh_token --- easyverein/api.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/easyverein/api.py b/easyverein/api.py index eedeabf..4ce7dfc 100644 --- a/easyverein/api.py +++ b/easyverein/api.py @@ -3,7 +3,7 @@ """ import logging -from typing import Callable +from typing import Callable, cast from .core.client import EasyvereinClient from .core.responses import BearerToken @@ -83,4 +83,9 @@ def refresh_token(self) -> BearerToken: raise ValueError("Refresh token is only available for API v2.0") response = self.c.fetch_one(self.c.get_url("/refresh-token")) - return parse_models(response.result, BearerToken) + token = parse_models(response.result, BearerToken) + if not token: + self.logger.error(f"Error refreshing token: {response.result}") + raise ValueError(f"Error refreshing token: {response.result}") + + return cast(BearerToken, token)