Skip to content
Open
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
17 changes: 14 additions & 3 deletions backend/python/app/sources/external/google/gmail/gmail.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ def __init__(
"""
self.client = client

# Cache references to the users().settings().getLanguage method for performance
self._get_language = self.client.users().settings().getLanguage

async def users_get_profile(
self,
userId: str,
Expand Down Expand Up @@ -1217,11 +1220,19 @@ async def users_settings_get_language(
Returns:
Dict[str, Any]: API response
"""
kwargs = kwargs or {}
# Avoid unnecessary dict allocation: only create a new dict if kwargs is None or not a dict
# Don't mutate input kwargs if it might be shared; instead, copy only if we insert.
if kwargs is None:
local_kwargs = {}
else:
# Only copy if we need to insert userId, else use as-is
local_kwargs = kwargs if userId is None else dict(kwargs)

if userId is not None:
kwargs['userId'] = userId
local_kwargs['userId'] = userId

request = self.client.users().settings().getLanguage(**kwargs) # type: ignore
# Use cached method reference for performance
request = self._get_language(**local_kwargs) # type: ignore
return request.execute()

async def users_settings_update_language(
Expand Down