Skip to content

Commit

Permalink
Fix list_accepted_access_requests if grant user manually (#2392)
Browse files Browse the repository at this point in the history
  • Loading branch information
Wauplin authored Jul 16, 2024
1 parent e370fa6 commit 6ddaf44
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/huggingface_hub/hf_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,8 +433,9 @@ class AccessRequest:
Username of the user who requested access.
fullname (`str`):
Fullname of the user who requested access.
email (`str`):
email (`Optional[str]`):
Email of the user who requested access.
Can only be `None` in the /accepted list if the user was granted access manually.
timestamp (`datetime`):
Timestamp of the request.
status (`Literal["pending", "accepted", "rejected"]`):
Expand All @@ -445,7 +446,7 @@ class AccessRequest:

username: str
fullname: str
email: str
email: Optional[str]
timestamp: datetime
status: Literal["pending", "accepted", "rejected"]

Expand Down Expand Up @@ -8462,7 +8463,7 @@ def _list_access_requests(
AccessRequest(
username=request["user"]["user"],
fullname=request["user"]["fullname"],
email=request["user"]["email"],
email=request["user"].get("email"),
status=request["status"],
timestamp=parse_datetime(request["timestamp"]),
fields=request.get("fields"), # only if custom fields in form
Expand Down
1 change: 1 addition & 0 deletions tests/test_hf_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3948,6 +3948,7 @@ def test_access_requests_normal_usage(self) -> None:
request = requests[0]
assert isinstance(request, AccessRequest)
assert request.username == OTHER_USER
assert request.email is None # email not shared when granted access manually
assert request.status == "accepted"
assert isinstance(request.timestamp, datetime.datetime)

Expand Down

0 comments on commit 6ddaf44

Please sign in to comment.