Skip to content

Commit fcf7063

Browse files
Update src/huggingface_hub/hf_api.py
Co-authored-by: célina <[email protected]>
1 parent 8463f98 commit fcf7063

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/huggingface_hub/hf_api.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1769,9 +1769,8 @@ def whoami(self, token: Union[bool, str, None] = None, *, cache: bool = False) -
17691769
"Hugging Face with `hf auth login` or `huggingface_hub.login`. See https://huggingface.co/settings/tokens."
17701770
)
17711771

1772-
if cache:
1773-
if token in self._whoami_cache:
1774-
return self._whoami_cache[token]
1772+
if cache and (cached_token := self._whoami_cache.get(token)):
1773+
return cached_token
17751774

17761775
# Call Hub
17771776
output = self._inner_whoami(token=token)

0 commit comments

Comments
 (0)