mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 22:13:26 +00:00
typing: Broaden type annotations for QuerySet compatibility.
To explain the rationale of this change, for example, there is `get_user_activity_summary` which accepts either a `Collection[UserActivity]`, where `QuerySet[T]` is not strictly `Sequence[T]` because its slicing behavior is different from the `Protocol`, making `Collection` necessary. Similarily, we should have `Iterable[T]` instead of `List[T]` so that `QuerySet[T]` will also be an acceptable subtype, or `Sequence[T]` when we also expect it to be indexed. Signed-off-by: Zixuan James Li <p359101898@gmail.com>
This commit is contained in:
committed by
Tim Abbott
parent
40fcf5a633
commit
ab1bbdda65
@@ -2,7 +2,19 @@ import copy
|
||||
import datetime
|
||||
import zlib
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Any, Dict, List, Mapping, Optional, Sequence, Set, Tuple, TypedDict, Union
|
||||
from typing import (
|
||||
Any,
|
||||
Collection,
|
||||
Dict,
|
||||
List,
|
||||
Mapping,
|
||||
Optional,
|
||||
Sequence,
|
||||
Set,
|
||||
Tuple,
|
||||
TypedDict,
|
||||
Union,
|
||||
)
|
||||
|
||||
import ahocorasick
|
||||
import orjson
|
||||
@@ -835,7 +847,7 @@ def has_message_access(
|
||||
|
||||
|
||||
def bulk_access_messages(
|
||||
user_profile: UserProfile, messages: Sequence[Message], *, stream: Optional[Stream] = None
|
||||
user_profile: UserProfile, messages: Collection[Message], *, stream: Optional[Stream] = None
|
||||
) -> List[Message]:
|
||||
"""This function does the full has_message_access check for each
|
||||
message. If stream is provided, it is used to avoid unnecessary
|
||||
|
||||
Reference in New Issue
Block a user