mirror of https://github.com/zulip/zulip.git
python: Unquote some unnecessarily quoted type annotations.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
6fe5cb65a1
commit
3bf8ee2156
|
@ -14,10 +14,7 @@ import shutil
|
|||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
from typing import TYPE_CHECKING, Optional
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import NoReturn
|
||||
from typing import NoReturn, Optional
|
||||
|
||||
os.environ["PYTHONUNBUFFERED"] = "y"
|
||||
|
||||
|
@ -47,7 +44,7 @@ logging.Formatter.converter = time.gmtime
|
|||
logging.basicConfig(format="%(asctime)s upgrade-zulip-stage-2: %(message)s", level=logging.INFO)
|
||||
|
||||
|
||||
def error_desupported_os(vendor: str, os_version: str) -> "NoReturn":
|
||||
def error_desupported_os(vendor: str, os_version: str) -> NoReturn:
|
||||
# Link to documentation for how to correctly upgrade the OS.
|
||||
logging.critical("Unsupported platform: %s %s", vendor, os_version)
|
||||
logging.info(
|
||||
|
|
|
@ -6,13 +6,13 @@ import os
|
|||
import platform
|
||||
import subprocess
|
||||
import sys
|
||||
from typing import List, NoReturn
|
||||
|
||||
os.environ["PYTHONUNBUFFERED"] = "y"
|
||||
|
||||
ZULIP_PATH = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
|
||||
sys.path.append(ZULIP_PATH)
|
||||
from typing import TYPE_CHECKING, List
|
||||
|
||||
from scripts.lib.node_cache import NODE_MODULES_CACHE_PATH, setup_node_modules
|
||||
from scripts.lib.setup_venv import get_venv_dependencies
|
||||
|
@ -27,9 +27,6 @@ from scripts.lib.zulip_tools import (
|
|||
)
|
||||
from tools.setup import setup_venvs
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from typing import NoReturn
|
||||
|
||||
VAR_DIR_PATH = os.path.join(ZULIP_PATH, "var")
|
||||
|
||||
CONTINUOUS_INTEGRATION = "GITHUB_ACTIONS" in os.environ
|
||||
|
@ -350,7 +347,7 @@ def install_yum_deps(deps_to_install: List[str]) -> None:
|
|||
)
|
||||
|
||||
|
||||
def main(options: argparse.Namespace) -> "NoReturn":
|
||||
def main(options: argparse.Namespace) -> NoReturn:
|
||||
|
||||
# yarn and management commands expect to be run from the root of the
|
||||
# project.
|
||||
|
|
|
@ -58,7 +58,7 @@ class RequestNotes(BaseNotes[HttpRequest, "RequestNotes"]):
|
|||
realm: Optional[Realm] = None
|
||||
has_fetched_realm: bool = False
|
||||
set_language: Optional[str] = None
|
||||
ratelimits_applied: List["rate_limiter.RateLimitResult"] = field(default_factory=lambda: [])
|
||||
ratelimits_applied: List[rate_limiter.RateLimitResult] = field(default_factory=lambda: [])
|
||||
query: Optional[str] = None
|
||||
error_format: Optional[str] = None
|
||||
placeholder_open_graph_description: Optional[str] = None
|
||||
|
|
|
@ -411,11 +411,11 @@ def access_stream_by_id(
|
|||
return (stream, sub)
|
||||
|
||||
|
||||
def get_public_streams_queryset(realm: Realm) -> "QuerySet[Stream]":
|
||||
def get_public_streams_queryset(realm: Realm) -> QuerySet[Stream]:
|
||||
return Stream.objects.filter(realm=realm, invite_only=False, history_public_to_subscribers=True)
|
||||
|
||||
|
||||
def get_web_public_streams_queryset(realm: Realm) -> "QuerySet[Stream]":
|
||||
def get_web_public_streams_queryset(realm: Realm) -> QuerySet[Stream]:
|
||||
# This should match the include_web_public code path in do_get_streams.
|
||||
return Stream.objects.filter(
|
||||
realm=realm,
|
||||
|
|
|
@ -70,19 +70,19 @@ DB_TOPIC_NAME = "subject"
|
|||
MESSAGE__TOPIC = "message__subject"
|
||||
|
||||
|
||||
def topic_match_sa(topic_name: str) -> "ColumnElement[Boolean]":
|
||||
def topic_match_sa(topic_name: str) -> ColumnElement[Boolean]:
|
||||
# _sa is short for SQLAlchemy, which we use mostly for
|
||||
# queries that search messages
|
||||
topic_cond = func.upper(column("subject", Text)) == func.upper(literal(topic_name))
|
||||
return topic_cond
|
||||
|
||||
|
||||
def get_resolved_topic_condition_sa() -> "ColumnElement[Boolean]":
|
||||
def get_resolved_topic_condition_sa() -> ColumnElement[Boolean]:
|
||||
resolved_topic_cond = column("subject", Text).startswith(RESOLVED_TOPIC_PREFIX)
|
||||
return resolved_topic_cond
|
||||
|
||||
|
||||
def topic_column_sa() -> "ColumnElement[Text]":
|
||||
def topic_column_sa() -> ColumnElement[Text]:
|
||||
return column("subject", Text)
|
||||
|
||||
|
||||
|
|
|
@ -120,7 +120,7 @@ def get_user_group_direct_member_ids(user_group: UserGroup) -> List[int]:
|
|||
)
|
||||
|
||||
|
||||
def get_user_group_direct_members(user_group: UserGroup) -> "QuerySet[UserGroup]":
|
||||
def get_user_group_direct_members(user_group: UserGroup) -> QuerySet[UserGroup]:
|
||||
return user_group.direct_members.all()
|
||||
|
||||
|
||||
|
@ -141,7 +141,7 @@ def get_direct_memberships_of_users(user_group: UserGroup, members: List[UserPro
|
|||
# https://code.djangoproject.com/ticket/28919
|
||||
|
||||
|
||||
def get_recursive_subgroups(user_group: UserGroup) -> "QuerySet[UserGroup]":
|
||||
def get_recursive_subgroups(user_group: UserGroup) -> QuerySet[UserGroup]:
|
||||
cte = With.recursive(
|
||||
lambda cte: UserGroup.objects.filter(id=user_group.id)
|
||||
.values("id")
|
||||
|
@ -150,11 +150,11 @@ def get_recursive_subgroups(user_group: UserGroup) -> "QuerySet[UserGroup]":
|
|||
return cte.join(UserGroup, id=cte.col.id).with_cte(cte)
|
||||
|
||||
|
||||
def get_recursive_group_members(user_group: UserGroup) -> "QuerySet[UserProfile]":
|
||||
def get_recursive_group_members(user_group: UserGroup) -> QuerySet[UserProfile]:
|
||||
return UserProfile.objects.filter(direct_groups__in=get_recursive_subgroups(user_group))
|
||||
|
||||
|
||||
def get_recursive_membership_groups(user_profile: UserProfile) -> "QuerySet[UserGroup]":
|
||||
def get_recursive_membership_groups(user_profile: UserProfile) -> QuerySet[UserGroup]:
|
||||
cte = With.recursive(
|
||||
lambda cte: user_profile.direct_groups.values("id").union(
|
||||
cte.join(UserGroup, direct_subgroups=cte.col.id).values("id")
|
||||
|
|
|
@ -164,7 +164,7 @@ def is_administrator_role(role: int) -> bool:
|
|||
|
||||
|
||||
def bulk_get_users(
|
||||
emails: List[str], realm: Optional[Realm], base_query: "QuerySet[UserProfile]" = None
|
||||
emails: List[str], realm: Optional[Realm], base_query: QuerySet[UserProfile] = None
|
||||
) -> Dict[str, UserProfile]:
|
||||
if base_query is None:
|
||||
assert realm is not None
|
||||
|
|
|
@ -696,7 +696,7 @@ class WildValueDict(WildValue):
|
|||
|
||||
return wrap_wild_value(var_name, item)
|
||||
|
||||
def get(self, key: str, default: object = None) -> "WildValue":
|
||||
def get(self, key: str, default: object = None) -> WildValue:
|
||||
item = self.value.get(key, default)
|
||||
if isinstance(item, WildValue):
|
||||
return item
|
||||
|
@ -705,11 +705,11 @@ class WildValueDict(WildValue):
|
|||
def keys(self) -> Iterator[str]:
|
||||
yield from self.value.keys()
|
||||
|
||||
def values(self) -> Iterator["WildValue"]:
|
||||
def values(self) -> Iterator[WildValue]:
|
||||
for key, value in self.value.items():
|
||||
yield wrap_wild_value(f"{self.var_name}[{key!r}]", value)
|
||||
|
||||
def items(self) -> Iterator[Tuple[str, "WildValue"]]:
|
||||
def items(self) -> Iterator[Tuple[str, WildValue]]:
|
||||
for key, value in self.value.items():
|
||||
yield key, wrap_wild_value(f"{self.var_name}[{key!r}]", value)
|
||||
|
||||
|
|
|
@ -105,10 +105,10 @@ TS_STOP = "</ts-match>"
|
|||
|
||||
|
||||
def ts_locs_array(
|
||||
config: "ColumnElement[Text]",
|
||||
text: "ColumnElement[Text]",
|
||||
tsquery: "ColumnElement[Any]",
|
||||
) -> "ColumnElement[ARRAY[Integer]]":
|
||||
config: ColumnElement[Text],
|
||||
text: ColumnElement[Text],
|
||||
tsquery: ColumnElement[Any],
|
||||
) -> ColumnElement[ARRAY[Integer]]:
|
||||
options = f"HighlightAll = TRUE, StartSel = {TS_START}, StopSel = {TS_STOP}"
|
||||
delimited = func.ts_headline(config, text, tsquery, options, type_=Text)
|
||||
part = func.unnest(
|
||||
|
@ -149,7 +149,7 @@ class NarrowBuilder:
|
|||
def __init__(
|
||||
self,
|
||||
user_profile: Optional[UserProfile],
|
||||
msg_id_column: "ColumnElement[Integer]",
|
||||
msg_id_column: ColumnElement[Integer],
|
||||
realm: Realm,
|
||||
is_web_public_query: bool = False,
|
||||
) -> None:
|
||||
|
@ -771,7 +771,7 @@ def exclude_muting_conditions(
|
|||
|
||||
def get_base_query_for_search(
|
||||
user_profile: Optional[UserProfile], need_message: bool, need_user_message: bool
|
||||
) -> Tuple[Select, "ColumnElement[Integer]"]:
|
||||
) -> Tuple[Select, ColumnElement[Integer]]:
|
||||
# Handle the simple case where user_message isn't involved first.
|
||||
if not need_user_message:
|
||||
assert need_message
|
||||
|
@ -809,7 +809,7 @@ def get_base_query_for_search(
|
|||
|
||||
def add_narrow_conditions(
|
||||
user_profile: Optional[UserProfile],
|
||||
inner_msg_id_col: "ColumnElement[Integer]",
|
||||
inner_msg_id_col: ColumnElement[Integer],
|
||||
query: Select,
|
||||
narrow: OptionalNarrowListT,
|
||||
is_web_public_query: bool,
|
||||
|
@ -1181,7 +1181,7 @@ def limit_query_to_range(
|
|||
anchor: int,
|
||||
anchored_to_left: bool,
|
||||
anchored_to_right: bool,
|
||||
id_col: "ColumnElement[Integer]",
|
||||
id_col: ColumnElement[Integer],
|
||||
first_visible_message_id: int,
|
||||
) -> SelectBase:
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue