Fix: Replace deprecated huggingface_hub.get_token_permission() with whoami() (#8913)

`get_token_permission` is deprecated and will be removed in huggingface_hub 1.0.
Use `whoami()` to validate the token instead, as recommended by the deprecation warning.
This commit is contained in:
Alexander Eichhorn 2026-02-28 16:59:45 +01:00 committed by GitHub
parent 4fd5cd26a0
commit ec46b5cb9e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1141,11 +1141,11 @@ class HFTokenHelper:
@classmethod
def get_status(cls) -> HFTokenStatus:
try:
if huggingface_hub.get_token_permission(huggingface_hub.get_token()):
# Valid token!
return HFTokenStatus.VALID
# No token set
return HFTokenStatus.INVALID
token = huggingface_hub.get_token()
if not token:
return HFTokenStatus.INVALID
huggingface_hub.whoami(token=token)
return HFTokenStatus.VALID
except Exception:
return HFTokenStatus.UNKNOWN