mirror of
https://github.com/zulip/zulip.git
synced 2025-11-09 00:18:12 +00:00
cache: Fix typing for generic_bulk_cached_fetch.
The typing for generic_bulk_cached_fetch is complicated, and was recorded incorrectly previously for the case where a cache_transformer function is required. We fix this by adding the new CacheItemT, and additionally add comments explaining what's going on with these types for future reference. Thanks to Mateusz Mandera for raising this issue.
This commit is contained in:
@@ -124,13 +124,16 @@ def bulk_get_users(emails: List[str], realm: Optional[Realm],
|
||||
where=[where_clause],
|
||||
params=emails)
|
||||
|
||||
def user_to_email(user_profile: UserProfile) -> str:
|
||||
return user_profile.email.lower()
|
||||
|
||||
return generic_bulk_cached_fetch(
|
||||
# Use a separate cache key to protect us from conflicts with
|
||||
# the get_user cache.
|
||||
lambda email: 'bulk_get_users:' + user_profile_cache_key_id(email, realm_id),
|
||||
fetch_users_by_email,
|
||||
[email.lower() for email in emails],
|
||||
id_fetcher=lambda user_profile: user_profile.email.lower()
|
||||
id_fetcher=user_to_email,
|
||||
)
|
||||
|
||||
def user_ids_to_users(user_ids: List[int], realm: Realm) -> List[UserProfile]:
|
||||
|
||||
Reference in New Issue
Block a user