Skip to content

Commit

Permalink
make get_user() return None if user not found
Browse files Browse the repository at this point in the history
  • Loading branch information
sir-sigurd committed Jun 13, 2024
1 parent 71be296 commit be2f5f8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
7 changes: 3 additions & 4 deletions api/python/quilt3/admin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,16 @@ def _get_client():
return Client()


def get_user(name: str) -> User:
def get_user(name: str) -> Optional[User]:
"""
Get a specific user from the registry.
Get a specific user from the registry. Return `None` if the user does not exist.
Args:
name: Username of user to get.
"""
result = _get_client().get_user(name=name)
# XXX: should we really throw an exception here?
if result is None:
raise UserNotFoundError
return None
return User.model_validate(result.model_dump())


Expand Down
4 changes: 2 additions & 2 deletions docs/api-reference/Admin.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ validated to form a valid model.

`self` is explicitly positional-only to allow `self` as a field name.

## get\_user(name: str) -> quilt3.admin.User {#get\_user}
## get\_user(name: str) -> Optional[quilt3.admin.User] {#get\_user}

Get a specific user from the registry.
Get a specific user from the registry. Return `None` if the user does not exist.

__Arguments__

Expand Down

0 comments on commit be2f5f8

Please sign in to comment.