Skip to content

Commit f2f55be

Browse files
committed
feat: remove verification of instance in the decorator and use delete_token response instead
1 parent f868bf2 commit f2f55be

2 files changed

Lines changed: 6 additions & 15 deletions

File tree

src/sumo/wrapper/_decorators.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# For sphinx:
22
from functools import wraps
33

4-
from sumo.wrapper._auth_provider import AuthProviderSumoToken
5-
64

75
def raise_for_status(func):
86
@wraps(func)
@@ -11,9 +9,7 @@ def wrapper(self, *args, **kwargs):
119
# so we could simply write
1210
# return func(*args, **kwargs).raise_for_status()
1311
response = func(self, *args, **kwargs)
14-
if response.status_code == 401 and isinstance(
15-
self.auth, AuthProviderSumoToken
16-
):
12+
if response.status_code == 401:
1713
self._handle_invalid_shared_key()
1814
response.raise_for_status()
1915
return response
@@ -28,9 +24,7 @@ async def wrapper(self, *args, **kwargs):
2824
# so we could simply write
2925
# return func(*args, **kwargs).raise_for_status()
3026
response = await func(self, *args, **kwargs)
31-
if response.status_code == 401 and isinstance(
32-
self.auth, AuthProviderSumoToken
33-
):
27+
if response.status_code == 401:
3428
self._handle_invalid_shared_key()
3529
response.raise_for_status()
3630
return response

src/sumo/wrapper/sumo_client.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -210,13 +210,10 @@ def blob_client(self) -> BlobClient:
210210

211211
def _handle_invalid_shared_key(self):
212212
"""Handle the invalid shared key by deleting it."""
213-
self.auth.delete_token()
214-
logger.error(
215-
"Invalid shared key detected and deleted, run again to reset automatically"
216-
)
217-
print(
218-
"Invalid shared key detected and deleted, run again to reset automatically"
219-
)
213+
if self.auth.delete_token():
214+
print(
215+
"Invalid shared key detected and deleted, run again to reset automatically"
216+
)
220217

221218
@raise_for_status
222219
def get(self, path: str, params: Optional[Dict] = None) -> httpx.Response:

0 commit comments

Comments
 (0)