Skip to content

Commit 9d772d5

Browse files
committed
thanks gemini
1 parent 0d1de4e commit 9d772d5

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

pyiceberg/io/fsspec.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -208,24 +208,20 @@ def _adls(properties: Properties) -> AbstractFileSystem:
208208
properties[ADLS_SAS_TOKEN] = sas_token
209209

210210
class StaticTokenCredential(AsyncTokenCredential):
211+
_DEFAULT_EXPIRY_SECONDS = 3600
212+
211213
def __init__(self, token_string: str) -> None:
212214
self._token = token_string
213-
# If no expiry provided, set 1 hour from now
214-
self._expires_on = int(time.time()) + 3600
215+
# Set expiration 1 hour from now
216+
self._expires_on = int(time.time()) + self._DEFAULT_EXPIRY_SECONDS
215217

216218
async def get_token(self, *scopes: str, **kwargs: Any) -> AccessToken:
217219
return AccessToken(self._token, self._expires_on)
218220

219-
if ADLS_TOKEN in properties:
220-
token = properties.get(ADLS_TOKEN)
221-
if token is not None:
222-
credential = StaticTokenCredential(token)
223-
else:
224-
credential = None
225-
elif ADLS_CREDENTIAL in properties:
226-
credential = properties.get(ADLS_CREDENTIAL)
221+
if token := properties.get(ADLS_TOKEN):
222+
credential = StaticTokenCredential(token)
227223
else:
228-
credential = None
224+
credential = properties.get(ADLS_CREDENTIAL) # type: ignore
229225

230226
return AzureBlobFileSystem(
231227
connection_string=properties.get(ADLS_CONNECTION_STRING),

0 commit comments

Comments
 (0)