Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions gotrue/_async/gotrue_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,11 @@ async def get_session(self) -> Union[Session, None]:
if current_session.expires_at
else False
)
if not has_expired:
return current_session
return await self._call_refresh_token(current_session.refresh_token)
return (
await self._call_refresh_token(current_session.refresh_token)
if has_expired
else current_session
)
Comment on lines -334 to +338
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function AsyncGoTrueClient.get_session refactored with the following changes:


async def get_user(self, jwt: Union[str, None] = None) -> UserResponse:
"""
Expand Down Expand Up @@ -582,7 +584,6 @@ async def _save_session(self, session: Session) -> None:
self._in_memory_session = session
expire_at = session.expires_at
if expire_at:
pass
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function AsyncGoTrueClient._save_session refactored with the following changes:

time_now = round(time())
expire_in = expire_at - time_now
refresh_duration_before_expires = (
Expand Down Expand Up @@ -648,8 +649,7 @@ def _get_valid_session(
except ValueError:
return None
try:
session = Session.parse_obj(data)
return session
return Session.parse_obj(data)
Comment on lines -651 to +652
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function AsyncGoTrueClient._get_valid_session refactored with the following changes:

except Exception:
return None

Expand All @@ -658,9 +658,7 @@ def _get_param(
query_params: Dict[str, List[str]],
name: str,
) -> Union[str, None]:
if name in query_params:
return query_params[name][0]
return None
return query_params[name][0] if name in query_params else None
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function AsyncGoTrueClient._get_param refactored with the following changes:


def _is_implicit_grant_flow(self, url: str) -> bool:
result = urlparse(url)
Expand Down
16 changes: 7 additions & 9 deletions gotrue/_sync/gotrue_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,11 @@ def get_session(self) -> Union[Session, None]:
if current_session.expires_at
else False
)
if not has_expired:
return current_session
return self._call_refresh_token(current_session.refresh_token)
return (
self._call_refresh_token(current_session.refresh_token)
if has_expired
else current_session
)
Comment on lines -334 to +338
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function SyncGoTrueClient.get_session refactored with the following changes:


def get_user(self, jwt: Union[str, None] = None) -> UserResponse:
"""
Expand Down Expand Up @@ -582,7 +584,6 @@ def _save_session(self, session: Session) -> None:
self._in_memory_session = session
expire_at = session.expires_at
if expire_at:
pass
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function SyncGoTrueClient._save_session refactored with the following changes:

time_now = round(time())
expire_in = expire_at - time_now
refresh_duration_before_expires = (
Expand Down Expand Up @@ -648,8 +649,7 @@ def _get_valid_session(
except ValueError:
return None
try:
session = Session.parse_obj(data)
return session
return Session.parse_obj(data)
Comment on lines -651 to +652
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function SyncGoTrueClient._get_valid_session refactored with the following changes:

except Exception:
return None

Expand All @@ -658,9 +658,7 @@ def _get_param(
query_params: Dict[str, List[str]],
name: str,
) -> Union[str, None]:
if name in query_params:
return query_params[name][0]
return None
return query_params[name][0] if name in query_params else None
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function SyncGoTrueClient._get_param refactored with the following changes:


def _is_implicit_grant_flow(self, url: str) -> bool:
result = urlparse(url)
Expand Down
5 changes: 1 addition & 4 deletions tests/_async/test_client_with_auto_confirm_disabled.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,7 @@ async def test_sign_in(client: AsyncGoTrueClient):
async def test_sign_in_with_the_wrong_password(client: AsyncGoTrueClient):
expected_error_message = "Invalid login credentials"
try:
await client.sign_in(
email=email,
password=password + "2",
)
await client.sign_in(email=email, password=f"{password}2")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function test_sign_in_with_the_wrong_password refactored with the following changes:

assert False
except APIError as e:
assert e.msg == expected_error_message
Expand Down
5 changes: 1 addition & 4 deletions tests/_sync/test_client_with_auto_confirm_disabled.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,7 @@ def test_sign_in(client: SyncGoTrueClient):
def test_sign_in_with_the_wrong_password(client: SyncGoTrueClient):
expected_error_message = "Invalid login credentials"
try:
client.sign_in(
email=email,
password=password + "2",
)
client.sign_in(email=email, password=f"{password}2")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function test_sign_in_with_the_wrong_password refactored with the following changes:

assert False
except APIError as e:
assert e.msg == expected_error_message
Expand Down