Skip to content

Commit

Permalink
fix: use directly parse_obj instead of lambdas
Browse files Browse the repository at this point in the history
  • Loading branch information
leynier committed Nov 6, 2021
1 parent 383298a commit 177b619
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
14 changes: 7 additions & 7 deletions gotrue/_async/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ async def sign_in_with_email(
data = {"email": email, "password": password}
url = f"{self.url}/token{query_string}"
response = await self.http_client.post(url, json=data, headers=headers)
return parse_response(response, lambda arg: Session.parse_obj(arg))
return parse_response(response, Session.parse_obj)

async def sign_up_with_phone(
self,
Expand Down Expand Up @@ -175,7 +175,7 @@ async def sign_in_with_phone(
data = {"phone": phone, "password": password}
url = f"{self.url}/token{query_string}"
response = await self.http_client.post(url, json=data, headers=headers)
return parse_response(response, lambda arg: Session.parse_obj(arg))
return parse_response(response, Session.parse_obj)

async def send_magic_link_email(
self,
Expand Down Expand Up @@ -304,7 +304,7 @@ async def invite_user_by_email(
data = {"email": email, "data": data}
url = f"{self.url}/invite{query_string}"
response = await self.http_client.post(url, json=data, headers=headers)
return parse_response(response, lambda arg: User.parse_obj(arg))
return parse_response(response, User.parse_obj)

async def reset_password_for_email(
self,
Expand Down Expand Up @@ -426,7 +426,7 @@ async def get_user(self, *, jwt: str) -> User:
headers = self._create_request_headers(jwt=jwt)
url = f"{self.url}/user"
response = await self.http_client.get(url, headers=headers)
return parse_response(response, lambda arg: User.parse_obj(arg))
return parse_response(response, User.parse_obj)

async def update_user(
self,
Expand Down Expand Up @@ -458,7 +458,7 @@ async def update_user(
data = attributes.dict()
url = f"{self.url}/user"
response = await self.http_client.put(url, json=data, headers=headers)
return parse_response(response, lambda arg: User.parse_obj(arg))
return parse_response(response, User.parse_obj)

async def delete_user(self, *, uid: str, jwt: str) -> User:
"""Delete a user. Requires a `service_role` key.
Expand Down Expand Up @@ -486,7 +486,7 @@ async def delete_user(self, *, uid: str, jwt: str) -> User:
headers = self._create_request_headers(jwt=jwt)
url = f"{self.url}/admin/users/${uid}"
response = await self.http_client.delete(url, headers=headers)
return parse_response(response, lambda arg: User.parse_obj(arg))
return parse_response(response, User.parse_obj)

async def refresh_access_token(self, *, refresh_token: str) -> Session:
"""Generates a new JWT.
Expand All @@ -511,7 +511,7 @@ async def refresh_access_token(self, *, refresh_token: str) -> Session:
data = {"refresh_token": refresh_token}
url = f"{self.url}/token{query_string}"
response = await self.http_client.post(url, json=data, headers=headers)
return parse_response(response, lambda arg: Session.parse_obj(arg))
return parse_response(response, Session.parse_obj)

async def generate_link(
self,
Expand Down
14 changes: 7 additions & 7 deletions gotrue/_sync/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def sign_in_with_email(
data = {"email": email, "password": password}
url = f"{self.url}/token{query_string}"
response = self.http_client.post(url, json=data, headers=headers)
return parse_response(response, lambda arg: Session.parse_obj(arg))
return parse_response(response, Session.parse_obj)

def sign_up_with_phone(
self,
Expand Down Expand Up @@ -175,7 +175,7 @@ def sign_in_with_phone(
data = {"phone": phone, "password": password}
url = f"{self.url}/token{query_string}"
response = self.http_client.post(url, json=data, headers=headers)
return parse_response(response, lambda arg: Session.parse_obj(arg))
return parse_response(response, Session.parse_obj)

def send_magic_link_email(
self,
Expand Down Expand Up @@ -304,7 +304,7 @@ def invite_user_by_email(
data = {"email": email, "data": data}
url = f"{self.url}/invite{query_string}"
response = self.http_client.post(url, json=data, headers=headers)
return parse_response(response, lambda arg: User.parse_obj(arg))
return parse_response(response, User.parse_obj)

def reset_password_for_email(
self,
Expand Down Expand Up @@ -426,7 +426,7 @@ def get_user(self, *, jwt: str) -> User:
headers = self._create_request_headers(jwt=jwt)
url = f"{self.url}/user"
response = self.http_client.get(url, headers=headers)
return parse_response(response, lambda arg: User.parse_obj(arg))
return parse_response(response, User.parse_obj)

def update_user(
self,
Expand Down Expand Up @@ -458,7 +458,7 @@ def update_user(
data = attributes.dict()
url = f"{self.url}/user"
response = self.http_client.put(url, json=data, headers=headers)
return parse_response(response, lambda arg: User.parse_obj(arg))
return parse_response(response, User.parse_obj)

def delete_user(self, *, uid: str, jwt: str) -> User:
"""Delete a user. Requires a `service_role` key.
Expand Down Expand Up @@ -486,7 +486,7 @@ def delete_user(self, *, uid: str, jwt: str) -> User:
headers = self._create_request_headers(jwt=jwt)
url = f"{self.url}/admin/users/${uid}"
response = self.http_client.delete(url, headers=headers)
return parse_response(response, lambda arg: User.parse_obj(arg))
return parse_response(response, User.parse_obj)

def refresh_access_token(self, *, refresh_token: str) -> Session:
"""Generates a new JWT.
Expand All @@ -511,7 +511,7 @@ def refresh_access_token(self, *, refresh_token: str) -> Session:
data = {"refresh_token": refresh_token}
url = f"{self.url}/token{query_string}"
response = self.http_client.post(url, json=data, headers=headers)
return parse_response(response, lambda arg: Session.parse_obj(arg))
return parse_response(response, Session.parse_obj)

def generate_link(
self,
Expand Down

0 comments on commit 177b619

Please sign in to comment.