ruff: Fix UP006 Use list instead of List for type annotation.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2024-07-11 17:30:17 -07:00
committed by Tim Abbott
parent c2214b3904
commit e08a24e47f
457 changed files with 3588 additions and 3857 deletions

View File

@@ -1,7 +1,7 @@
import logging
from collections import defaultdict
from datetime import datetime
from typing import Callable, Dict, List, Optional, Tuple, TypedDict
from typing import Callable, Optional, TypedDict
from django.db import connection, transaction
from django.db.models import QuerySet
@@ -22,7 +22,7 @@ def get_user_topics(
include_deactivated: bool = False,
include_stream_name: bool = False,
visibility_policy: Optional[int] = None,
) -> List[UserTopicDict]:
) -> list[UserTopicDict]:
"""
Fetches UserTopic objects associated with the target user.
* include_deactivated: Whether to include those associated with
@@ -65,7 +65,7 @@ def get_user_topics(
def get_topic_mutes(
user_profile: UserProfile, include_deactivated: bool = False
) -> List[Tuple[str, str, int]]:
) -> list[tuple[str, str, int]]:
user_topics = get_user_topics(
user_profile=user_profile,
include_deactivated=include_deactivated,
@@ -82,7 +82,7 @@ def get_topic_mutes(
@transaction.atomic(savepoint=False)
def set_topic_visibility_policy(
user_profile: UserProfile,
topics: List[List[str]],
topics: list[list[str]],
visibility_policy: int,
last_updated: Optional[datetime] = None,
) -> None:
@@ -129,14 +129,14 @@ def get_topic_visibility_policy(
@transaction.atomic(savepoint=False)
def bulk_set_user_topic_visibility_policy_in_database(
user_profiles: List[UserProfile],
user_profiles: list[UserProfile],
stream_id: int,
topic_name: str,
*,
visibility_policy: int,
recipient_id: Optional[int] = None,
last_updated: Optional[datetime] = None,
) -> List[UserProfile]:
) -> list[UserProfile]:
# returns the list of user_profiles whose user_topic row
# is either deleted, updated, or created.
rows = UserTopic.objects.filter(
@@ -163,7 +163,7 @@ def bulk_set_user_topic_visibility_policy_in_database(
assert last_updated is not None
assert recipient_id is not None
user_profiles_seeking_user_topic_update_or_create: List[UserProfile] = (
user_profiles_seeking_user_topic_update_or_create: list[UserProfile] = (
user_profiles_without_visibility_policy
)
for row in rows:
@@ -228,8 +228,8 @@ def topic_has_visibility_policy(
def exclude_topic_mutes(
conditions: List[ClauseElement], user_profile: UserProfile, stream_id: Optional[int]
) -> List[ClauseElement]:
conditions: list[ClauseElement], user_profile: UserProfile, stream_id: Optional[int]
) -> list[ClauseElement]:
# Note: Unlike get_topic_mutes, here we always want to
# consider topics in deactivated streams, so they are
# never filtered from the query in this method.
@@ -281,7 +281,7 @@ def build_get_topic_visibility_policy(
"visibility_policy",
)
topic_to_visibility_policy: Dict[Tuple[int, str], int] = defaultdict(int)
topic_to_visibility_policy: dict[tuple[int, str], int] = defaultdict(int)
for row in rows:
recipient_id = row["recipient_id"]
topic_name = row["topic_name"]