mirror of
https://github.com/zulip/zulip.git
synced 2025-10-28 18:43:52 +00:00
ruff: Fix UP006 Use list instead of List for type annotation.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
c2214b3904
commit
e08a24e47f
@@ -1,7 +1,7 @@
|
||||
import itertools
|
||||
from collections import defaultdict
|
||||
from datetime import timedelta
|
||||
from typing import AbstractSet, Any, Dict, Iterable, List, Optional, Set, Tuple
|
||||
from typing import AbstractSet, Any, Iterable, Optional
|
||||
|
||||
from django.conf import settings
|
||||
from django.db import transaction
|
||||
@@ -84,7 +84,7 @@ from zerver.models.users import get_system_bot
|
||||
from zerver.tornado.django_api import send_event_on_commit
|
||||
|
||||
|
||||
def subscriber_info(user_id: int) -> Dict[str, Any]:
|
||||
def subscriber_info(user_id: int) -> dict[str, Any]:
|
||||
return {"id": user_id, "flags": ["read"]}
|
||||
|
||||
|
||||
@@ -148,7 +148,7 @@ def maybe_send_resolve_topic_notifications(
|
||||
new_topic_name: str,
|
||||
changed_messages: QuerySet[Message],
|
||||
pre_truncation_new_topic_name: str,
|
||||
) -> Tuple[Optional[int], bool]:
|
||||
) -> tuple[Optional[int], bool]:
|
||||
"""Returns resolved_topic_message_id if resolve topic notifications were in fact sent."""
|
||||
# Note that topics will have already been stripped in check_update_message.
|
||||
resolved_prefix_len = len(RESOLVED_TOPIC_PREFIX)
|
||||
@@ -299,7 +299,7 @@ def send_message_moved_breadcrumbs(
|
||||
)
|
||||
|
||||
|
||||
def get_mentions_for_message_updates(message_id: int) -> Set[int]:
|
||||
def get_mentions_for_message_updates(message_id: int) -> set[int]:
|
||||
# We exclude UserMessage.flags.historical rows since those
|
||||
# users did not receive the message originally, and thus
|
||||
# probably are not relevant for reprocessed alert_words,
|
||||
@@ -330,7 +330,7 @@ def update_user_message_flags(
|
||||
) -> None:
|
||||
mentioned_ids = rendering_result.mentions_user_ids
|
||||
ids_with_alert_words = rendering_result.user_ids_with_alert_words
|
||||
changed_ums: Set[UserMessage] = set()
|
||||
changed_ums: set[UserMessage] = set()
|
||||
|
||||
def update_flag(um: UserMessage, should_set: bool, flag: int) -> None:
|
||||
if should_set:
|
||||
@@ -366,7 +366,7 @@ def do_update_embedded_data(
|
||||
rendering_result: MessageRenderingResult,
|
||||
) -> None:
|
||||
timestamp = timezone_now()
|
||||
event: Dict[str, Any] = {
|
||||
event: dict[str, Any] = {
|
||||
"type": "update_message",
|
||||
"user_id": None,
|
||||
"edit_timestamp": datetime_to_timestamp(timestamp),
|
||||
@@ -390,7 +390,7 @@ def do_update_embedded_data(
|
||||
|
||||
event["message_ids"] = update_message_cache(changed_messages)
|
||||
|
||||
def user_info(um: UserMessage) -> Dict[str, Any]:
|
||||
def user_info(um: UserMessage) -> dict[str, Any]:
|
||||
return {
|
||||
"id": um.user_profile_id,
|
||||
"flags": um.flags_list(),
|
||||
@@ -433,7 +433,7 @@ def do_update_message(
|
||||
send_notification_to_new_thread: bool,
|
||||
content: Optional[str],
|
||||
rendering_result: Optional[MessageRenderingResult],
|
||||
prior_mention_user_ids: Set[int],
|
||||
prior_mention_user_ids: set[int],
|
||||
mention_data: Optional[MentionData] = None,
|
||||
) -> int:
|
||||
"""
|
||||
@@ -452,7 +452,7 @@ def do_update_message(
|
||||
timestamp = timezone_now()
|
||||
target_message.last_edit_time = timestamp
|
||||
|
||||
event: Dict[str, Any] = {
|
||||
event: dict[str, Any] = {
|
||||
"type": "update_message",
|
||||
"user_id": user_profile.id,
|
||||
"edit_timestamp": datetime_to_timestamp(timestamp),
|
||||
@@ -586,7 +586,7 @@ def do_update_message(
|
||||
event["propagate_mode"] = propagate_mode
|
||||
|
||||
users_losing_access = UserProfile.objects.none()
|
||||
user_ids_gaining_usermessages: List[int] = []
|
||||
user_ids_gaining_usermessages: list[int] = []
|
||||
if new_stream is not None:
|
||||
assert content is None
|
||||
assert target_message.is_stream_message()
|
||||
@@ -798,7 +798,7 @@ def do_update_message(
|
||||
|
||||
event["message_ids"] = update_message_cache(changed_messages, realm_id)
|
||||
|
||||
def user_info(um: UserMessage) -> Dict[str, Any]:
|
||||
def user_info(um: UserMessage) -> dict[str, Any]:
|
||||
return {
|
||||
"id": um.user_profile_id,
|
||||
"flags": um.flags_list(),
|
||||
@@ -908,9 +908,9 @@ def do_update_message(
|
||||
assert target_stream is not None
|
||||
assert target_topic_name is not None
|
||||
|
||||
stream_inaccessible_to_user_profiles: List[UserProfile] = []
|
||||
orig_topic_user_profile_to_visibility_policy: Dict[UserProfile, int] = {}
|
||||
target_topic_user_profile_to_visibility_policy: Dict[UserProfile, int] = {}
|
||||
stream_inaccessible_to_user_profiles: list[UserProfile] = []
|
||||
orig_topic_user_profile_to_visibility_policy: dict[UserProfile, int] = {}
|
||||
target_topic_user_profile_to_visibility_policy: dict[UserProfile, int] = {}
|
||||
user_ids_losing_access = {user.id for user in users_losing_access}
|
||||
for user_topic in get_users_with_user_topic_visibility_policy(
|
||||
stream_being_edited.id, orig_topic_name
|
||||
@@ -930,14 +930,14 @@ def do_update_message(
|
||||
)
|
||||
|
||||
# User profiles having any of the visibility policies set for either the original or target topic.
|
||||
user_profiles_having_visibility_policy: Set[UserProfile] = set(
|
||||
user_profiles_having_visibility_policy: set[UserProfile] = set(
|
||||
itertools.chain(
|
||||
orig_topic_user_profile_to_visibility_policy.keys(),
|
||||
target_topic_user_profile_to_visibility_policy.keys(),
|
||||
)
|
||||
)
|
||||
|
||||
user_profiles_for_visibility_policy_pair: Dict[Tuple[int, int], List[UserProfile]] = (
|
||||
user_profiles_for_visibility_policy_pair: dict[tuple[int, int], list[UserProfile]] = (
|
||||
defaultdict(list)
|
||||
)
|
||||
for user_profile_with_policy in user_profiles_having_visibility_policy:
|
||||
@@ -1197,7 +1197,7 @@ def check_time_limit_for_change_all_propagate_mode(
|
||||
message__recipient_id=message.recipient_id,
|
||||
message__subject__iexact=message.topic_name(),
|
||||
).values_list("message_id", flat=True)
|
||||
messages_allowed_to_move: List[int] = list(
|
||||
messages_allowed_to_move: list[int] = list(
|
||||
Message.objects.filter(
|
||||
# Uses index: zerver_message_pkey
|
||||
id__in=accessible_messages_in_topic,
|
||||
@@ -1291,8 +1291,8 @@ def check_update_message(
|
||||
raise JsonableError(_("The time limit for editing this message's topic has passed."))
|
||||
|
||||
rendering_result = None
|
||||
links_for_embed: Set[str] = set()
|
||||
prior_mention_user_ids: Set[int] = set()
|
||||
links_for_embed: set[str] = set()
|
||||
prior_mention_user_ids: set[int] = set()
|
||||
mention_data: Optional[MentionData] = None
|
||||
if content is not None:
|
||||
if content.rstrip() == "":
|
||||
|
||||
Reference in New Issue
Block a user