mirror of https://github.com/zulip/zulip.git
python: Reformat with Ruff formatter.
https://docs.astral.sh/ruff/formatter/ Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
c85b2edbd4
commit
570f3dd447
|
@ -1461,9 +1461,7 @@ class TestLoggingCountStats(AnalyticsTestCase):
|
|||
), mock.patch("zilencer.views.send_apple_push_notification", return_value=1), mock.patch(
|
||||
"corporate.lib.stripe.RemoteServerBillingSession.current_count_for_billed_licenses",
|
||||
return_value=10,
|
||||
), self.assertLogs(
|
||||
"zilencer.views", level="INFO"
|
||||
):
|
||||
), self.assertLogs("zilencer.views", level="INFO"):
|
||||
result = self.uuid_post(
|
||||
self.server_uuid,
|
||||
"/api/v1/remotes/push/notify",
|
||||
|
@ -1522,9 +1520,7 @@ class TestLoggingCountStats(AnalyticsTestCase):
|
|||
), mock.patch("zilencer.views.send_apple_push_notification", return_value=1), mock.patch(
|
||||
"corporate.lib.stripe.RemoteServerBillingSession.current_count_for_billed_licenses",
|
||||
return_value=10,
|
||||
), self.assertLogs(
|
||||
"zilencer.views", level="INFO"
|
||||
):
|
||||
), self.assertLogs("zilencer.views", level="INFO"):
|
||||
result = self.uuid_post(
|
||||
self.server_uuid,
|
||||
"/api/v1/remotes/push/notify",
|
||||
|
@ -1582,9 +1578,7 @@ class TestLoggingCountStats(AnalyticsTestCase):
|
|||
), mock.patch("zilencer.views.send_apple_push_notification", return_value=1), mock.patch(
|
||||
"corporate.lib.stripe.RemoteRealmBillingSession.current_count_for_billed_licenses",
|
||||
return_value=10,
|
||||
), self.assertLogs(
|
||||
"zilencer.views", level="INFO"
|
||||
):
|
||||
), self.assertLogs("zilencer.views", level="INFO"):
|
||||
result = self.uuid_post(
|
||||
self.server_uuid,
|
||||
"/api/v1/remotes/push/notify",
|
||||
|
|
|
@ -38,7 +38,7 @@ def is_self_hosting_management_subdomain(request: HttpRequest) -> bool:
|
|||
|
||||
|
||||
def self_hosting_management_endpoint(
|
||||
view_func: Callable[Concatenate[HttpRequest, ParamT], HttpResponse]
|
||||
view_func: Callable[Concatenate[HttpRequest, ParamT], HttpResponse],
|
||||
) -> Callable[Concatenate[HttpRequest, ParamT], HttpResponse]:
|
||||
@wraps(view_func)
|
||||
def _wrapped_view_func(
|
||||
|
@ -52,7 +52,7 @@ def self_hosting_management_endpoint(
|
|||
|
||||
|
||||
def authenticated_remote_realm_management_endpoint(
|
||||
view_func: Callable[Concatenate[HttpRequest, RemoteRealmBillingSession, ParamT], HttpResponse]
|
||||
view_func: Callable[Concatenate[HttpRequest, RemoteRealmBillingSession, ParamT], HttpResponse],
|
||||
) -> Callable[Concatenate[HttpRequest, ParamT], HttpResponse]:
|
||||
@wraps(view_func)
|
||||
def _wrapped_view_func(
|
||||
|
@ -152,7 +152,7 @@ def get_next_page_param_from_request_path(request: HttpRequest) -> Optional[str]
|
|||
|
||||
|
||||
def authenticated_remote_server_management_endpoint(
|
||||
view_func: Callable[Concatenate[HttpRequest, RemoteServerBillingSession, ParamT], HttpResponse]
|
||||
view_func: Callable[Concatenate[HttpRequest, RemoteServerBillingSession, ParamT], HttpResponse],
|
||||
) -> Callable[Concatenate[HttpRequest, ParamT], HttpResponse]:
|
||||
@wraps(view_func)
|
||||
def _wrapped_view_func(
|
||||
|
|
|
@ -5,7 +5,6 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("corporate", "0037_customerplanoffer"),
|
||||
]
|
||||
|
|
|
@ -51,7 +51,6 @@ def backfill_end_date_for_fixed_price_plans(
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("corporate", "0038_customerplanoffer_sent_invoice_id_invoice"),
|
||||
]
|
||||
|
|
|
@ -4,7 +4,6 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("corporate", "0039_backfill_end_date_for_fixed_price_plans"),
|
||||
]
|
||||
|
|
|
@ -143,7 +143,7 @@ def get_identity_dict_from_signed_access_token(
|
|||
|
||||
|
||||
def is_tos_consent_needed_for_user(
|
||||
remote_user: Union[RemoteRealmBillingUser, RemoteServerBillingUser]
|
||||
remote_user: Union[RemoteRealmBillingUser, RemoteServerBillingUser],
|
||||
) -> bool:
|
||||
assert settings.TERMS_OF_SERVICE_VERSION is not None
|
||||
return int(settings.TERMS_OF_SERVICE_VERSION.split(".")[0]) > int(
|
||||
|
@ -323,9 +323,9 @@ def remote_realm_billing_finalize_login(
|
|||
|
||||
identity_dict["remote_billing_user_id"] = remote_user.id
|
||||
request.session["remote_billing_identities"] = {}
|
||||
request.session["remote_billing_identities"][
|
||||
f"remote_realm:{remote_realm_uuid}"
|
||||
] = identity_dict
|
||||
request.session["remote_billing_identities"][f"remote_realm:{remote_realm_uuid}"] = (
|
||||
identity_dict
|
||||
)
|
||||
|
||||
next_page = identity_dict["next_page"]
|
||||
assert next_page in VALID_NEXT_PAGES
|
||||
|
|
|
@ -8,6 +8,7 @@ This script works by just monitoring the files under
|
|||
mirrors when they receive the messages sent every minute by
|
||||
/etc/cron.d/test_zephyr_personal_mirrors
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
|
|
|
@ -6,6 +6,7 @@ Nagios plugin to check that our MIT users' Zephyr mirrors are running.
|
|||
It must be run on a machine that is using the live database for the
|
||||
Django ORM.
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
from datetime import timedelta
|
||||
|
|
|
@ -9,6 +9,7 @@ run out of cron.
|
|||
|
||||
See puppet/kandra/files/cron.d/zephyr-mirror for the crontab details.
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
#!/usr/bin/env python3
|
||||
""" Nagios plugin paired with a cron job. This just verifies that the
|
||||
"""
|
||||
Nagios plugin paired with a cron job. This just verifies that the
|
||||
file output by the cron job is correct.
|
||||
"""
|
||||
|
||||
import sys
|
||||
import time
|
||||
from typing import Tuple
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
"""
|
||||
Nagios plugin to check that none of our queue workers have reported errors.
|
||||
"""
|
||||
|
||||
import glob
|
||||
import os
|
||||
import sys
|
||||
|
|
|
@ -6,6 +6,7 @@ Script to provide information about send-receive times.
|
|||
It must be run on a machine that is using the live database for the
|
||||
Django ORM.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import random
|
||||
|
|
|
@ -6,6 +6,7 @@ connects to PostgreSQL as has been granted the `pg_monitor` role.
|
|||
|
||||
This can only use stdlib modules from python.
|
||||
"""
|
||||
|
||||
import configparser
|
||||
import re
|
||||
import subprocess
|
||||
|
|
|
@ -150,6 +150,7 @@ ignore = [
|
|||
"E402", # Module level import not at top of file
|
||||
"E501", # Line too long
|
||||
"E731", # Do not assign a lambda expression, use a def
|
||||
"ISC001", # Implicitly concatenated string literals on one line
|
||||
"N802", # Function name should be lowercase
|
||||
"N806", # Variable in function should be lowercase
|
||||
"PERF203", # `try`-`except` within a loop incurs performance overhead
|
||||
|
|
|
@ -38,8 +38,8 @@ Also you can use optional keys to configure the script and change default values
|
|||
self-signed certificates. Default value: False.
|
||||
|
||||
-t Disable sending request to the Zulip server. Default value: False.
|
||||
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import base64
|
||||
import json
|
||||
|
|
|
@ -31,7 +31,7 @@ FAIL = "\033[91m"
|
|||
ENDC = "\033[0m"
|
||||
BLACKONYELLOW = "\x1b[0;30;43m"
|
||||
WHITEONRED = "\x1b[0;37;41m"
|
||||
BOLDRED = "\x1B[1;31m"
|
||||
BOLDRED = "\x1b[1;31m"
|
||||
BOLD = "\x1b[1m"
|
||||
GRAY = "\x1b[90m"
|
||||
|
||||
|
|
|
@ -239,8 +239,6 @@ if change_symlink and "PWD" in os.environ:
|
|||
which has now changed. Your shell will not see this change until you run:
|
||||
cd {}
|
||||
to traverse the symlink again.{}
|
||||
""".format(
|
||||
WARNING, symlink, shlex.quote(os.environ["PWD"]), ENDC
|
||||
),
|
||||
""".format(WARNING, symlink, shlex.quote(os.environ["PWD"]), ENDC),
|
||||
file=sys.stderr,
|
||||
)
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
Fetch contributors data from GitHub using their API, convert it to structured
|
||||
JSON data for the /team/ page contributors section.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import logging
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#!/usr/bin/env python3
|
||||
import argparse
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
|
||||
tools_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
|
@ -168,13 +167,11 @@ def run() -> None:
|
|||
description="Formats CSS, JavaScript, YAML",
|
||||
)
|
||||
linter_config.external_linter(
|
||||
"black",
|
||||
["black"],
|
||||
"ruff-format",
|
||||
["ruff", "format"],
|
||||
["py", "pyi"],
|
||||
description="Reformats Python code",
|
||||
check_arg=["--check"],
|
||||
suppress_line=lambda line: line == "All done! ✨ 🍰 ✨\n"
|
||||
or re.fullmatch(r"\d+ files? would be left unchanged\.\n", line) is not None,
|
||||
)
|
||||
|
||||
semgrep_command = [
|
||||
|
|
|
@ -107,7 +107,7 @@ def emoji_is_supported(emoji_dict: Dict[str, Any]) -> bool:
|
|||
|
||||
|
||||
def generate_codepoint_to_names_map(
|
||||
emoji_name_maps: Dict[str, Dict[str, Any]]
|
||||
emoji_name_maps: Dict[str, Dict[str, Any]],
|
||||
) -> Dict[str, List[str]]:
|
||||
# The first element of the names list is always the canonical name.
|
||||
return {
|
||||
|
|
|
@ -133,9 +133,7 @@ def do_update_user_presence(
|
|||
# and also is under the risk of being shown by clients as offline before the next regular presence checkin
|
||||
# (so at least `settings.OFFLINE_THRESHOLD_SECS - settings.PRESENCE_PING_INTERVAL_SECS - 10`).
|
||||
# These two values happen to be the same in the default configuration.
|
||||
seconds=settings.OFFLINE_THRESHOLD_SECS
|
||||
- settings.PRESENCE_PING_INTERVAL_SECS
|
||||
- 10
|
||||
seconds=settings.OFFLINE_THRESHOLD_SECS - settings.PRESENCE_PING_INTERVAL_SECS - 10
|
||||
)
|
||||
became_online = status == UserPresence.LEGACY_STATUS_ACTIVE_INT and now_online
|
||||
|
||||
|
|
|
@ -93,9 +93,8 @@ def zulip_default_corporate_context(request: HttpRequest) -> Dict[str, Any]:
|
|||
from corporate.lib.decorator import is_self_hosting_management_subdomain
|
||||
|
||||
# Check if view function is in corporate app.
|
||||
if (
|
||||
request.resolver_match is not None
|
||||
and not request.resolver_match.func.__module__.startswith("corporate")
|
||||
if request.resolver_match is not None and not request.resolver_match.func.__module__.startswith(
|
||||
"corporate"
|
||||
):
|
||||
return {
|
||||
"is_self_hosting_management_page": False,
|
||||
|
|
|
@ -806,7 +806,7 @@ def write_emoticon_data(
|
|||
|
||||
|
||||
def create_username_to_user_mapping(
|
||||
user_data_list: List[Dict[str, Any]]
|
||||
user_data_list: List[Dict[str, Any]],
|
||||
) -> Dict[str, Dict[str, Any]]:
|
||||
username_to_user = {}
|
||||
for user in user_data_list:
|
||||
|
|
|
@ -105,7 +105,7 @@ def update_user_activity(
|
|||
|
||||
# Based on django.views.decorators.http.require_http_methods
|
||||
def require_post(
|
||||
func: Callable[Concatenate[HttpRequest, ParamT], HttpResponse]
|
||||
func: Callable[Concatenate[HttpRequest, ParamT], HttpResponse],
|
||||
) -> Callable[Concatenate[HttpRequest, ParamT], HttpResponse]:
|
||||
# Arguments before ParamT needs to be positional-only as required by Concatenate
|
||||
@wraps(func)
|
||||
|
@ -132,7 +132,7 @@ def require_post(
|
|||
|
||||
|
||||
def require_realm_owner(
|
||||
func: Callable[Concatenate[HttpRequest, UserProfile, ParamT], HttpResponse]
|
||||
func: Callable[Concatenate[HttpRequest, UserProfile, ParamT], HttpResponse],
|
||||
) -> Callable[Concatenate[HttpRequest, UserProfile, ParamT], HttpResponse]:
|
||||
@wraps(func)
|
||||
def wrapper(
|
||||
|
@ -150,7 +150,7 @@ def require_realm_owner(
|
|||
|
||||
|
||||
def require_realm_admin(
|
||||
func: Callable[Concatenate[HttpRequest, UserProfile, ParamT], HttpResponse]
|
||||
func: Callable[Concatenate[HttpRequest, UserProfile, ParamT], HttpResponse],
|
||||
) -> Callable[Concatenate[HttpRequest, UserProfile, ParamT], HttpResponse]:
|
||||
@wraps(func)
|
||||
def wrapper(
|
||||
|
@ -168,7 +168,7 @@ def require_realm_admin(
|
|||
|
||||
|
||||
def require_organization_member(
|
||||
func: Callable[Concatenate[HttpRequest, UserProfile, ParamT], HttpResponse]
|
||||
func: Callable[Concatenate[HttpRequest, UserProfile, ParamT], HttpResponse],
|
||||
) -> Callable[Concatenate[HttpRequest, UserProfile, ParamT], HttpResponse]:
|
||||
@wraps(func)
|
||||
def wrapper(
|
||||
|
@ -186,7 +186,7 @@ def require_organization_member(
|
|||
|
||||
|
||||
def require_billing_access(
|
||||
func: Callable[Concatenate[HttpRequest, UserProfile, ParamT], HttpResponse]
|
||||
func: Callable[Concatenate[HttpRequest, UserProfile, ParamT], HttpResponse],
|
||||
) -> Callable[Concatenate[HttpRequest, UserProfile, ParamT], HttpResponse]:
|
||||
@wraps(func)
|
||||
def wrapper(
|
||||
|
@ -429,7 +429,7 @@ def user_passes_test(
|
|||
"""
|
||||
|
||||
def decorator(
|
||||
view_func: Callable[Concatenate[HttpRequest, ParamT], HttpResponse]
|
||||
view_func: Callable[Concatenate[HttpRequest, ParamT], HttpResponse],
|
||||
) -> Callable[Concatenate[HttpRequest, ParamT], HttpResponse]:
|
||||
@wraps(view_func)
|
||||
def _wrapped_view(
|
||||
|
@ -481,9 +481,9 @@ def do_login(request: HttpRequest, user_profile: UserProfile) -> None:
|
|||
assert isinstance(validated_user_profile, UserProfile)
|
||||
|
||||
django_login(request, validated_user_profile)
|
||||
RequestNotes.get_notes(request).requester_for_logs = (
|
||||
validated_user_profile.format_requester_for_logs()
|
||||
)
|
||||
RequestNotes.get_notes(
|
||||
request
|
||||
).requester_for_logs = validated_user_profile.format_requester_for_logs()
|
||||
process_client(request, validated_user_profile, is_browser_view=True)
|
||||
if settings.TWO_FACTOR_AUTHENTICATION_ENABLED:
|
||||
# Log in with two factor authentication as well.
|
||||
|
@ -491,7 +491,7 @@ def do_login(request: HttpRequest, user_profile: UserProfile) -> None:
|
|||
|
||||
|
||||
def log_view_func(
|
||||
view_func: Callable[Concatenate[HttpRequest, ParamT], HttpResponse]
|
||||
view_func: Callable[Concatenate[HttpRequest, ParamT], HttpResponse],
|
||||
) -> Callable[Concatenate[HttpRequest, ParamT], HttpResponse]:
|
||||
@wraps(view_func)
|
||||
def _wrapped_view_func(
|
||||
|
@ -504,7 +504,7 @@ def log_view_func(
|
|||
|
||||
|
||||
def add_logging_data(
|
||||
view_func: Callable[Concatenate[HttpRequest, ParamT], HttpResponse]
|
||||
view_func: Callable[Concatenate[HttpRequest, ParamT], HttpResponse],
|
||||
) -> Callable[Concatenate[HttpRequest, ParamT], HttpResponse]:
|
||||
@wraps(view_func)
|
||||
def _wrapped_view_func(
|
||||
|
@ -523,7 +523,7 @@ def add_logging_data(
|
|||
|
||||
|
||||
def human_users_only(
|
||||
view_func: Callable[Concatenate[HttpRequest, ParamT], HttpResponse]
|
||||
view_func: Callable[Concatenate[HttpRequest, ParamT], HttpResponse],
|
||||
) -> Callable[Concatenate[HttpRequest, ParamT], HttpResponse]:
|
||||
@wraps(view_func)
|
||||
def _wrapped_view_func(
|
||||
|
@ -597,7 +597,7 @@ def web_public_view(
|
|||
|
||||
|
||||
def require_server_admin(
|
||||
view_func: Callable[Concatenate[HttpRequest, ParamT], HttpResponse]
|
||||
view_func: Callable[Concatenate[HttpRequest, ParamT], HttpResponse],
|
||||
) -> Callable[Concatenate[HttpRequest, ParamT], HttpResponse]:
|
||||
@zulip_login_required
|
||||
@wraps(view_func)
|
||||
|
@ -613,7 +613,7 @@ def require_server_admin(
|
|||
|
||||
|
||||
def require_server_admin_api(
|
||||
view_func: Callable[Concatenate[HttpRequest, ParamT], HttpResponse]
|
||||
view_func: Callable[Concatenate[HttpRequest, ParamT], HttpResponse],
|
||||
) -> Callable[Concatenate[HttpRequest, ParamT], HttpResponse]:
|
||||
@zulip_login_required
|
||||
@wraps(view_func)
|
||||
|
@ -631,7 +631,7 @@ def require_server_admin_api(
|
|||
|
||||
|
||||
def require_non_guest_user(
|
||||
view_func: Callable[Concatenate[HttpRequest, UserProfile, ParamT], HttpResponse]
|
||||
view_func: Callable[Concatenate[HttpRequest, UserProfile, ParamT], HttpResponse],
|
||||
) -> Callable[Concatenate[HttpRequest, UserProfile, ParamT], HttpResponse]:
|
||||
@wraps(view_func)
|
||||
def _wrapped_view_func(
|
||||
|
@ -649,7 +649,7 @@ def require_non_guest_user(
|
|||
|
||||
|
||||
def require_member_or_admin(
|
||||
view_func: Callable[Concatenate[HttpRequest, UserProfile, ParamT], HttpResponse]
|
||||
view_func: Callable[Concatenate[HttpRequest, UserProfile, ParamT], HttpResponse],
|
||||
) -> Callable[Concatenate[HttpRequest, UserProfile, ParamT], HttpResponse]:
|
||||
@wraps(view_func)
|
||||
def _wrapped_view_func(
|
||||
|
@ -669,7 +669,7 @@ def require_member_or_admin(
|
|||
|
||||
|
||||
def require_user_group_edit_permission(
|
||||
view_func: Callable[Concatenate[HttpRequest, UserProfile, ParamT], HttpResponse]
|
||||
view_func: Callable[Concatenate[HttpRequest, UserProfile, ParamT], HttpResponse],
|
||||
) -> Callable[Concatenate[HttpRequest, UserProfile, ParamT], HttpResponse]:
|
||||
@require_member_or_admin
|
||||
@wraps(view_func)
|
||||
|
@ -756,7 +756,7 @@ def authenticated_rest_api_view(
|
|||
allow_webhook_access = True
|
||||
|
||||
def _wrapped_view_func(
|
||||
view_func: Callable[Concatenate[HttpRequest, UserProfile, ParamT], HttpResponse]
|
||||
view_func: Callable[Concatenate[HttpRequest, UserProfile, ParamT], HttpResponse],
|
||||
) -> Callable[Concatenate[HttpRequest, ParamT], HttpResponse]:
|
||||
@csrf_exempt
|
||||
@wraps(view_func)
|
||||
|
@ -809,7 +809,7 @@ def authenticated_rest_api_view(
|
|||
|
||||
|
||||
def process_as_post(
|
||||
view_func: Callable[Concatenate[HttpRequest, ParamT], HttpResponse]
|
||||
view_func: Callable[Concatenate[HttpRequest, ParamT], HttpResponse],
|
||||
) -> Callable[Concatenate[HttpRequest, ParamT], HttpResponse]:
|
||||
@wraps(view_func)
|
||||
def _wrapped_view_func(
|
||||
|
@ -938,7 +938,7 @@ def internal_api_view(
|
|||
the server."""
|
||||
|
||||
def _wrapped_view_func(
|
||||
view_func: Callable[Concatenate[HttpRequest, ParamT], HttpResponse]
|
||||
view_func: Callable[Concatenate[HttpRequest, ParamT], HttpResponse],
|
||||
) -> Callable[Concatenate[HttpRequest, ParamT], HttpResponse]:
|
||||
@csrf_exempt
|
||||
@require_post
|
||||
|
@ -969,7 +969,7 @@ def to_utc_datetime(var_name: str, timestamp: str) -> datetime:
|
|||
|
||||
|
||||
def return_success_on_head_request(
|
||||
view_func: Callable[Concatenate[HttpRequest, ParamT], HttpResponse]
|
||||
view_func: Callable[Concatenate[HttpRequest, ParamT], HttpResponse],
|
||||
) -> Callable[Concatenate[HttpRequest, ParamT], HttpResponse]:
|
||||
@wraps(view_func)
|
||||
def _wrapped_view_func(
|
||||
|
@ -1044,7 +1044,7 @@ def add_google_analytics_context(context: Dict[str, object]) -> None:
|
|||
|
||||
|
||||
def add_google_analytics(
|
||||
view_func: Callable[Concatenate[HttpRequest, ParamT], HttpResponse]
|
||||
view_func: Callable[Concatenate[HttpRequest, ParamT], HttpResponse],
|
||||
) -> Callable[Concatenate[HttpRequest, ParamT], HttpResponse]:
|
||||
@wraps(view_func)
|
||||
def _wrapped_view_func(
|
||||
|
|
|
@ -724,7 +724,8 @@ class IgnoreUnhashableLruCacheWrapper(Generic[ParamT, ReturnT]):
|
|||
|
||||
try:
|
||||
return self.cached_function(
|
||||
*args, **kwargs # type: ignore[arg-type] # might be unhashable
|
||||
*args,
|
||||
**kwargs, # type: ignore[arg-type] # might be unhashable
|
||||
)
|
||||
except TypeError:
|
||||
# args or kwargs contains an element which is unhashable. In
|
||||
|
@ -750,7 +751,7 @@ def ignore_unhashable_lru_cache(
|
|||
internal_decorator = lru_cache(maxsize=maxsize, typed=typed)
|
||||
|
||||
def decorator(
|
||||
user_function: Callable[ParamT, ReturnT]
|
||||
user_function: Callable[ParamT, ReturnT],
|
||||
) -> IgnoreUnhashableLruCacheWrapper[ParamT, ReturnT]:
|
||||
return IgnoreUnhashableLruCacheWrapper(user_function, internal_decorator(user_function))
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ def generate_dev_ldap_dir(mode: str, num_users: int = 8) -> Dict[str, Dict[str,
|
|||
|
||||
|
||||
def init_fakeldap(
|
||||
directory: Optional[Dict[str, Dict[str, List[str]]]] = None
|
||||
directory: Optional[Dict[str, Dict[str, List[str]]]] = None,
|
||||
) -> None: # nocoverage
|
||||
# We only use this in development. Importing mock inside
|
||||
# this function is an import time optimization, which
|
||||
|
|
|
@ -79,7 +79,7 @@ def further_validated_draft_dict(
|
|||
|
||||
|
||||
def draft_endpoint(
|
||||
view_func: Callable[Concatenate[HttpRequest, UserProfile, ParamT], HttpResponse]
|
||||
view_func: Callable[Concatenate[HttpRequest, UserProfile, ParamT], HttpResponse],
|
||||
) -> Callable[Concatenate[HttpRequest, UserProfile, ParamT], HttpResponse]:
|
||||
@wraps(view_func)
|
||||
def draft_view_func(
|
||||
|
|
|
@ -219,8 +219,7 @@ def fetch_initial_state_data(
|
|||
# user_topic and muted_topics, and receive the duplicate
|
||||
# muted_topics data only from older servers that don't yet
|
||||
# support user_topic.
|
||||
event_types is None
|
||||
or not want("user_topic")
|
||||
event_types is None or not want("user_topic")
|
||||
):
|
||||
state["muted_topics"] = [] if user_profile is None else get_topic_mutes(user_profile)
|
||||
|
||||
|
@ -415,12 +414,12 @@ def fetch_initial_state_data(
|
|||
realm_user_default, property_name
|
||||
)
|
||||
|
||||
state["realm_user_settings_defaults"][
|
||||
"emojiset_choices"
|
||||
] = RealmUserDefault.emojiset_choices()
|
||||
state["realm_user_settings_defaults"][
|
||||
"available_notification_sounds"
|
||||
] = get_available_notification_sounds()
|
||||
state["realm_user_settings_defaults"]["emojiset_choices"] = (
|
||||
RealmUserDefault.emojiset_choices()
|
||||
)
|
||||
state["realm_user_settings_defaults"]["available_notification_sounds"] = (
|
||||
get_available_notification_sounds()
|
||||
)
|
||||
|
||||
if want("realm_domains"):
|
||||
state["realm_domains"] = get_realm_domains(realm)
|
||||
|
@ -662,9 +661,9 @@ def fetch_initial_state_data(
|
|||
|
||||
state["user_settings"]["emojiset_choices"] = UserProfile.emojiset_choices()
|
||||
state["user_settings"]["timezone"] = canonicalize_timezone(settings_user.timezone)
|
||||
state["user_settings"][
|
||||
"available_notification_sounds"
|
||||
] = get_available_notification_sounds()
|
||||
state["user_settings"]["available_notification_sounds"] = (
|
||||
get_available_notification_sounds()
|
||||
)
|
||||
|
||||
if want("user_status"):
|
||||
# We require creating an account to access statuses.
|
||||
|
|
|
@ -565,9 +565,7 @@ def export_from_config(
|
|||
if config.custom_tables:
|
||||
exported_tables = config.custom_tables
|
||||
else:
|
||||
assert (
|
||||
table is not None
|
||||
), """
|
||||
assert table is not None, """
|
||||
You must specify config.custom_tables if you
|
||||
are not specifying config.table"""
|
||||
exported_tables = [table]
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
"""
|
||||
This module stores data for "external account" custom profile field.
|
||||
This module stores data for "external account" custom profile field.
|
||||
"""
|
||||
|
||||
from dataclasses import dataclass
|
||||
|
|
|
@ -262,7 +262,7 @@ class MessageDict:
|
|||
|
||||
@staticmethod
|
||||
def sew_submessages_and_reactions_to_msgs(
|
||||
messages: List[Dict[str, Any]]
|
||||
messages: List[Dict[str, Any]],
|
||||
) -> List[Dict[str, Any]]:
|
||||
msg_ids = [msg["id"] for msg in messages]
|
||||
submessages = SubMessage.get_raw_db_rows(msg_ids)
|
||||
|
|
|
@ -968,7 +968,8 @@ def get_base_query_for_search(
|
|||
# zerver_messages, since the user_profile_id limit in
|
||||
# usermessage is more selective, and the query planner
|
||||
# can't know about that cross-table correlation.
|
||||
.where(column("user_profile_id", Integer) == literal(user_profile.id)).select_from(
|
||||
.where(column("user_profile_id", Integer) == literal(user_profile.id))
|
||||
.select_from(
|
||||
join(
|
||||
table("zerver_usermessage"),
|
||||
table("zerver_message"),
|
||||
|
|
|
@ -880,7 +880,9 @@ def get_mobile_push_content(rendered_content: str) -> str:
|
|||
|
||||
def format_as_quote(quote_text: str) -> str:
|
||||
return "".join(
|
||||
f"> {line}\n" for line in quote_text.splitlines() if line # Remove empty lines
|
||||
f"> {line}\n"
|
||||
for line in quote_text.splitlines()
|
||||
if line # Remove empty lines
|
||||
)
|
||||
|
||||
def render_olist(ol: lxml.html.HtmlElement) -> str:
|
||||
|
|
|
@ -335,7 +335,7 @@ ReturnT = TypeVar("ReturnT")
|
|||
# expected to call json_success or raise JsonableError, as it uses JsonableError
|
||||
# internally when it encounters an error
|
||||
def has_request_variables(
|
||||
req_func: Callable[Concatenate[HttpRequest, ParamT], ReturnT]
|
||||
req_func: Callable[Concatenate[HttpRequest, ParamT], ReturnT],
|
||||
) -> Callable[Concatenate[HttpRequest, ParamT], ReturnT]:
|
||||
num_params = req_func.__code__.co_argcount
|
||||
default_param_values = cast(FunctionType, req_func).__defaults__
|
||||
|
|
|
@ -24,7 +24,7 @@ METHODS = ("GET", "HEAD", "POST", "PUT", "DELETE", "PATCH")
|
|||
|
||||
|
||||
def default_never_cache_responses(
|
||||
view_func: Callable[Concatenate[HttpRequest, ParamT], HttpResponse]
|
||||
view_func: Callable[Concatenate[HttpRequest, ParamT], HttpResponse],
|
||||
) -> Callable[Concatenate[HttpRequest, ParamT], HttpResponse]:
|
||||
"""Patched version of the standard Django never_cache_responses
|
||||
decorator that adds headers to a response so that it will never be
|
||||
|
|
|
@ -272,7 +272,7 @@ def do_soft_deactivate_user(user_profile: UserProfile) -> None:
|
|||
|
||||
|
||||
def do_soft_deactivate_users(
|
||||
users: Union[Sequence[UserProfile], QuerySet[UserProfile]]
|
||||
users: Union[Sequence[UserProfile], QuerySet[UserProfile]],
|
||||
) -> List[UserProfile]:
|
||||
BATCH_SIZE = 100
|
||||
users_soft_deactivated = []
|
||||
|
|
|
@ -1544,9 +1544,7 @@ Output:
|
|||
"""
|
||||
with mock.patch(
|
||||
"zerver.lib.markdown.timeout", side_effect=subprocess.CalledProcessError(1, [])
|
||||
), self.assertLogs(
|
||||
level="ERROR"
|
||||
): # For markdown_logger.exception
|
||||
), self.assertLogs(level="ERROR"): # For markdown_logger.exception
|
||||
yield
|
||||
|
||||
def create_default_device(
|
||||
|
|
|
@ -585,7 +585,7 @@ TestCaseT = TypeVar("TestCaseT", bound="MigrationsTestCase")
|
|||
|
||||
|
||||
def use_db_models(
|
||||
method: Callable[[TestCaseT, StateApps], None]
|
||||
method: Callable[[TestCaseT, StateApps], None],
|
||||
) -> Callable[[TestCaseT, StateApps], None]: # nocoverage
|
||||
def method_patched_with_mock(self: TestCaseT, apps: StateApps) -> None:
|
||||
ArchivedAttachment = apps.get_model("zerver", "ArchivedAttachment")
|
||||
|
|
|
@ -278,7 +278,7 @@ def parse_single_parameter(
|
|||
|
||||
|
||||
def parse_view_func_signature(
|
||||
view_func: Callable[Concatenate[HttpRequest, ParamT], object]
|
||||
view_func: Callable[Concatenate[HttpRequest, ParamT], object],
|
||||
) -> ViewFuncInfo:
|
||||
"""This is responsible for inspecting the function signature and getting the
|
||||
metadata from the parameters. We want to keep this function as pure as
|
||||
|
|
|
@ -747,9 +747,9 @@ def get_subscribers_of_target_user_subscriptions(
|
|||
for user_id in target_user_ids:
|
||||
target_user_subbed_recipients = target_user_subscriptions_dict[user_id]
|
||||
for recipient_id in target_user_subbed_recipients:
|
||||
users_subbed_to_target_user_subscriptions_dict[
|
||||
user_id
|
||||
] |= subscribers_dict_by_recipient_ids[recipient_id]
|
||||
users_subbed_to_target_user_subscriptions_dict[user_id] |= (
|
||||
subscribers_dict_by_recipient_ids[recipient_id]
|
||||
)
|
||||
|
||||
return users_subbed_to_target_user_subscriptions_dict
|
||||
|
||||
|
|
|
@ -117,7 +117,9 @@ def do_bulk_backfill_extra_data(
|
|||
continue
|
||||
new_value = ast.literal_eval(audit_log_entry.extra_data) # type: ignore[attr-defined] # Explained above.
|
||||
if old_value not in ({}, new_value):
|
||||
inconsistent_extra_data_json.append((audit_log_entry.id, audit_log_entry.extra_data, old_value, new_value)) # type: ignore[attr-defined] # Explained above.
|
||||
inconsistent_extra_data_json.append(
|
||||
(audit_log_entry.id, audit_log_entry.extra_data, old_value, new_value) # type: ignore[attr-defined] # Explained above.
|
||||
)
|
||||
audit_log_entry.extra_data_json = new_value # type: ignore[attr-defined] # Explained above.
|
||||
audit_log_model._default_manager.bulk_update(
|
||||
python_valued_audit_log_entries, fields=["extra_data_json"]
|
||||
|
|
|
@ -29,9 +29,7 @@ def populate_read_by_sender(apps: StateApps, schema_editor: BaseDatabaseSchemaEd
|
|||
| Q(sending_client_name_lower__contains="desktop app"),
|
||||
~Q(recipient=F("sender__recipient")),
|
||||
read_by_sender=None,
|
||||
).update(
|
||||
read_by_sender=True
|
||||
)
|
||||
).update(read_by_sender=True)
|
||||
ScheduledMessage.objects.filter(read_by_sender=None).update(read_by_sender=False)
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ from django.db import migrations
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("zerver", "0496_alter_scheduledmessage_read_by_sender"),
|
||||
]
|
||||
|
|
|
@ -4,7 +4,6 @@ from django.db import migrations
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("zerver", "0497_resort_edit_history"),
|
||||
]
|
||||
|
|
|
@ -4,7 +4,6 @@ from django.db import migrations
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("zerver", "0498_rename_notifications_stream_realm_new_stream_announcements_stream"),
|
||||
]
|
||||
|
|
|
@ -17,7 +17,6 @@ def set_initial_value_for_zulip_update_announcements_stream(
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("zerver", "0499_rename_signup_notifications_stream_realm_signup_announcements_stream"),
|
||||
]
|
||||
|
|
|
@ -603,8 +603,9 @@ class UserProfile(AbstractBaseUser, PermissionsMixin, UserBaseSettings):
|
|||
for field in custom_profile_fields_for_realm(self.realm_id):
|
||||
field_values = user_data.get(field.id, None)
|
||||
if field_values:
|
||||
value, rendered_value = field_values.get("value"), field_values.get(
|
||||
"rendered_value"
|
||||
value, rendered_value = (
|
||||
field_values.get("value"),
|
||||
field_values.get("rendered_value"),
|
||||
)
|
||||
else:
|
||||
value, rendered_value = None, None
|
||||
|
|
|
@ -7256,9 +7256,7 @@ class LDAPBackendTest(ZulipTestCase):
|
|||
"zproject.backends.ZulipLDAPAuthBackend.get_or_build_user", side_effect=error
|
||||
), mock.patch("django_auth_ldap.backend._LDAPUser._authenticate_user_dn"), self.assertLogs(
|
||||
"django_auth_ldap", "WARNING"
|
||||
) as warn_log, self.assertLogs(
|
||||
"django.request", level="ERROR"
|
||||
):
|
||||
) as warn_log, self.assertLogs("django.request", level="ERROR"):
|
||||
response = self.client_post("/login/", data)
|
||||
self.assertEqual(response.status_code, 500)
|
||||
self.assert_in_response("Configuration error", response)
|
||||
|
|
|
@ -10,8 +10,7 @@ from zerver.lib.test_classes import ZulipTestCase
|
|||
|
||||
|
||||
class VersionTest(ZulipTestCase):
|
||||
data = (
|
||||
[
|
||||
data = [
|
||||
case.split()
|
||||
for case in """
|
||||
1.2.3 < 1.2.4
|
||||
|
@ -30,15 +29,11 @@ class VersionTest(ZulipTestCase):
|
|||
15.1.95 < 16.2.96
|
||||
16.2.96 = 16.2.96
|
||||
20.0.103 > 16.2.96
|
||||
""".strip().split(
|
||||
"\n"
|
||||
)
|
||||
]
|
||||
+ [
|
||||
""".strip().split("\n")
|
||||
] + [
|
||||
["", "?", "1"],
|
||||
["", "?", "a"],
|
||||
]
|
||||
)
|
||||
|
||||
def test_version_lt(self) -> None:
|
||||
for ver1, cmp, ver2 in self.data:
|
||||
|
@ -65,9 +60,7 @@ class VersionTest(ZulipTestCase):
|
|||
ios ZulipMobile/1.2.3 (iPhone OS 2.1)
|
||||
ios ZulipMobile/1.2.3 (iOS 6)
|
||||
None ZulipMobile/1.2.3 (Windows 8)
|
||||
""".strip().split(
|
||||
"\n"
|
||||
)
|
||||
""".strip().split("\n")
|
||||
]
|
||||
|
||||
def test_find_mobile_os(self) -> None:
|
||||
|
@ -97,9 +90,7 @@ class CompatibilityTest(ZulipTestCase):
|
|||
ok ZulipMobile/1 CFNetwork/974.2.1 Darwin/18.0.0
|
||||
ok ZulipMobile/20.0.103 (Android 6.0.1)
|
||||
ok ZulipMobile/20.0.103 (iOS 12.1)
|
||||
""".strip().split(
|
||||
"\n"
|
||||
)
|
||||
""".strip().split("\n")
|
||||
if case
|
||||
]
|
||||
|
||||
|
|
|
@ -196,9 +196,7 @@ class OpenGraphParserTestCase(ZulipTestCase):
|
|||
<head>
|
||||
<meta property="og:title" content="中文" />
|
||||
</head>
|
||||
</html>""".encode(
|
||||
"big5"
|
||||
)
|
||||
</html>""".encode("big5")
|
||||
parser = OpenGraphParser(html, "text/html; charset=Big5")
|
||||
result = parser.extract_data()
|
||||
self.assertEqual(result.title, "中文")
|
||||
|
@ -209,9 +207,7 @@ class OpenGraphParserTestCase(ZulipTestCase):
|
|||
<meta content-type="text/html; charset=Big5" />
|
||||
<meta property="og:title" content="中文" />
|
||||
</head>
|
||||
</html>""".encode(
|
||||
"big5"
|
||||
)
|
||||
</html>""".encode("big5")
|
||||
parser = OpenGraphParser(html, "text/html")
|
||||
result = parser.extract_data()
|
||||
self.assertEqual(result.title, "中文")
|
||||
|
|
|
@ -1302,7 +1302,7 @@ class MarkdownTest(ZulipTestCase):
|
|||
assert_conversion("Hello #123World", False)
|
||||
assert_conversion("Hello#123 World", False)
|
||||
assert_conversion("Hello#123World", False)
|
||||
assert_conversion("Hello\u00A0#123\u00A0World")
|
||||
assert_conversion("Hello\u00a0#123\u00a0World")
|
||||
# Ideally, these should be converted, but Markdown doesn't
|
||||
# handle word boundary detection in languages that don't use
|
||||
# whitespace for that correctly yet.
|
||||
|
|
|
@ -924,7 +924,7 @@ class MessagePOSTTest(ZulipTestCase):
|
|||
{
|
||||
"type": "stream",
|
||||
"to": "Verona",
|
||||
"topic": "Test\uFFFETopic",
|
||||
"topic": "Test\ufffeTopic",
|
||||
"content": "Test message",
|
||||
},
|
||||
)
|
||||
|
|
|
@ -256,9 +256,7 @@ class SendTestPushNotificationEndpointTest(BouncerTestCase):
|
|||
"zerver.lib.push_notifications.send_apple_push_notification"
|
||||
) as mock_send_apple_push_notification, mock.patch(
|
||||
"zerver.lib.push_notifications.send_android_push_notification"
|
||||
) as mock_send_android_push_notification, time_machine.travel(
|
||||
time_now, tick=False
|
||||
):
|
||||
) as mock_send_android_push_notification, time_machine.travel(time_now, tick=False):
|
||||
result = self.api_post(user, endpoint, subdomain="zulip")
|
||||
|
||||
mock_send_android_push_notification.assert_called_once_with(
|
||||
|
@ -595,9 +593,7 @@ class PushBouncerNotificationTest(BouncerTestCase):
|
|||
), mock.patch("zilencer.views.send_apple_push_notification", return_value=1), mock.patch(
|
||||
"corporate.lib.stripe.RemoteRealmBillingSession.current_count_for_billed_licenses",
|
||||
return_value=10,
|
||||
), self.assertLogs(
|
||||
"zilencer.views", level="INFO"
|
||||
):
|
||||
), self.assertLogs("zilencer.views", level="INFO"):
|
||||
result = self.uuid_post(
|
||||
self.server_uuid,
|
||||
"/api/v1/remotes/push/notify",
|
||||
|
@ -669,9 +665,7 @@ class PushBouncerNotificationTest(BouncerTestCase):
|
|||
) as apple_push, mock.patch(
|
||||
"corporate.lib.stripe.RemoteRealmBillingSession.current_count_for_billed_licenses",
|
||||
return_value=10,
|
||||
), time_machine.travel(
|
||||
time_sent, tick=False
|
||||
), self.assertLogs(
|
||||
), time_machine.travel(time_sent, tick=False), self.assertLogs(
|
||||
"zilencer.views", level="INFO"
|
||||
) as logger:
|
||||
result = self.uuid_post(
|
||||
|
@ -989,9 +983,7 @@ class PushBouncerNotificationTest(BouncerTestCase):
|
|||
), mock.patch("zilencer.views.send_apple_push_notification", return_value=1), mock.patch(
|
||||
"corporate.lib.stripe.RemoteServerBillingSession.current_count_for_billed_licenses",
|
||||
return_value=10,
|
||||
), self.assertLogs(
|
||||
"zilencer.views", level="INFO"
|
||||
) as logger:
|
||||
), self.assertLogs("zilencer.views", level="INFO") as logger:
|
||||
result = self.uuid_post(
|
||||
self.server_uuid,
|
||||
"/api/v1/remotes/push/notify",
|
||||
|
@ -2774,9 +2766,7 @@ class HandlePushNotificationTest(PushNotificationTest):
|
|||
return_value=10,
|
||||
), self.assertLogs(
|
||||
"zerver.lib.push_notifications", level="INFO"
|
||||
) as pn_logger, self.assertLogs(
|
||||
"zilencer.views", level="INFO"
|
||||
) as views_logger:
|
||||
) as pn_logger, self.assertLogs("zilencer.views", level="INFO") as views_logger:
|
||||
apns_devices = [
|
||||
(b64_to_hex(device.token), device.ios_app_id, device.token)
|
||||
for device in RemotePushDeviceToken.objects.filter(kind=PushDeviceToken.APNS)
|
||||
|
@ -2867,9 +2857,7 @@ class HandlePushNotificationTest(PushNotificationTest):
|
|||
return_value=100,
|
||||
) as mock_current_count, self.assertLogs(
|
||||
"zerver.lib.push_notifications", level="INFO"
|
||||
) as pn_logger, self.assertLogs(
|
||||
"zilencer.views", level="INFO"
|
||||
):
|
||||
) as pn_logger, self.assertLogs("zilencer.views", level="INFO"):
|
||||
handle_push_notification(self.user_profile.id, missed_message)
|
||||
|
||||
self.assertEqual(
|
||||
|
@ -2938,9 +2926,7 @@ class HandlePushNotificationTest(PushNotificationTest):
|
|||
return_value=10,
|
||||
), self.assertLogs(
|
||||
"zerver.lib.push_notifications", level="INFO"
|
||||
) as pn_logger, self.assertLogs(
|
||||
"zilencer.views", level="INFO"
|
||||
) as views_logger:
|
||||
) as pn_logger, self.assertLogs("zilencer.views", level="INFO") as views_logger:
|
||||
apns_devices = [
|
||||
(b64_to_hex(device.token), device.ios_app_id, device.token)
|
||||
for device in RemotePushDeviceToken.objects.filter(kind=PushDeviceToken.APNS)
|
||||
|
|
|
@ -676,9 +676,7 @@ class WorkerTest(ZulipTestCase):
|
|||
"zerver.lib.send_email.build_email", side_effect=EmailNotDeliveredError
|
||||
), mock_queue_publish(
|
||||
"zerver.lib.queue.queue_json_publish", side_effect=fake_publish
|
||||
), self.assertLogs(
|
||||
level="ERROR"
|
||||
) as m:
|
||||
), self.assertLogs(level="ERROR") as m:
|
||||
worker.start()
|
||||
self.assertIn("failed due to exception EmailNotDeliveredError", m.output[0])
|
||||
|
||||
|
|
|
@ -760,9 +760,7 @@ class MoveMessageToArchiveGeneral(MoveMessageToArchiveBase):
|
|||
Some more.... http://{host}/user_uploads/{id}/31/4CBjtTLYZhk66pZrF8hnYGwc/abc.py ...
|
||||
http://{host}/user_uploads/{id}/31/4CBjtTLYZhk66pZrF8hnYGwc/new.py ....
|
||||
http://{host}/user_uploads/{id}/31/4CBjtTLYZhk66pZrF8hnYGwc/hello.txt ....
|
||||
""".format(
|
||||
id=realm_id, host=host
|
||||
)
|
||||
""".format(id=realm_id, host=host)
|
||||
|
||||
msg_id = self.send_personal_message(self.sender, self.recipient, body)
|
||||
# Simulate a reply with the same contents.
|
||||
|
@ -821,9 +819,7 @@ class MoveMessageToArchiveGeneral(MoveMessageToArchiveBase):
|
|||
Some more.... http://{host}/user_uploads/{id}/31/4CBjtTLYZhk66pZrF8hnYGwc/abc.py ...
|
||||
http://{host}/user_uploads/{id}/31/4CBjtTLYZhk66pZrF8hnYGwc/new.py ....
|
||||
http://{host}/user_uploads/{id}/31/4CBjtTLYZhk66pZrF8hnYGwc/hello.txt ....
|
||||
""".format(
|
||||
id=realm_id, host=host
|
||||
)
|
||||
""".format(id=realm_id, host=host)
|
||||
|
||||
msg_id = self.send_personal_message(self.sender, self.recipient, body)
|
||||
|
||||
|
|
|
@ -422,7 +422,7 @@ ParamT = ParamSpec("ParamT")
|
|||
|
||||
|
||||
def for_all_bot_types(
|
||||
test_func: Callable[Concatenate["TestServiceBotEventTriggers", ParamT], None]
|
||||
test_func: Callable[Concatenate["TestServiceBotEventTriggers", ParamT], None],
|
||||
) -> Callable[Concatenate["TestServiceBotEventTriggers", ParamT], None]:
|
||||
@wraps(test_func)
|
||||
def _wrapped(
|
||||
|
@ -443,7 +443,7 @@ def patch_queue_publish(
|
|||
Callable[["TestServiceBotEventTriggers"], None],
|
||||
]:
|
||||
def inner(
|
||||
func: Callable[["TestServiceBotEventTriggers", mock.Mock], None]
|
||||
func: Callable[["TestServiceBotEventTriggers", mock.Mock], None],
|
||||
) -> Callable[["TestServiceBotEventTriggers"], None]:
|
||||
@wraps(func)
|
||||
def _wrapped(self: "TestServiceBotEventTriggers") -> None:
|
||||
|
|
|
@ -3996,7 +3996,7 @@ class SubscriptionAPITest(ZulipTestCase):
|
|||
# For Cn category
|
||||
post_data_cn = {
|
||||
"subscriptions": orjson.dumps(
|
||||
[{"name": "new\uFFFEstream", "description": "this is description"}]
|
||||
[{"name": "new\ufffestream", "description": "this is description"}]
|
||||
).decode(),
|
||||
"invite_only": orjson.dumps(False).decode(),
|
||||
}
|
||||
|
@ -4023,7 +4023,7 @@ class SubscriptionAPITest(ZulipTestCase):
|
|||
result = self.client_patch(f"/json/streams/{stream.id}", {"new_name": "test\n\rname"})
|
||||
self.assert_json_error(result, "Invalid character in stream name, at position 5!")
|
||||
# Check for Cn characters
|
||||
result = self.client_patch(f"/json/streams/{stream.id}", {"new_name": "test\uFFFEame"})
|
||||
result = self.client_patch(f"/json/streams/{stream.id}", {"new_name": "test\ufffeame"})
|
||||
self.assert_json_error(result, "Invalid character in stream name, at position 5!")
|
||||
|
||||
def test_successful_subscriptions_list(self) -> None:
|
||||
|
|
|
@ -631,7 +631,7 @@ def oauth_redirect_to_root(
|
|||
|
||||
|
||||
def handle_desktop_flow(
|
||||
func: Callable[Concatenate[HttpRequest, ParamT], HttpResponse]
|
||||
func: Callable[Concatenate[HttpRequest, ParamT], HttpResponse],
|
||||
) -> Callable[Concatenate[HttpRequest, ParamT], HttpResponse]:
|
||||
@wraps(func)
|
||||
def wrapper(
|
||||
|
|
|
@ -120,7 +120,8 @@ def serve_local(
|
|||
# the response to; serve it directly ourselves. FileResponse
|
||||
# handles setting Content-Type, Content-Disposition, etc.
|
||||
response: HttpResponseBase = FileResponse(
|
||||
open(local_path, "rb"), as_attachment=download # noqa: SIM115
|
||||
open(local_path, "rb"), # noqa: SIM115
|
||||
as_attachment=download,
|
||||
)
|
||||
patch_cache_control(response, private=True, immutable=True)
|
||||
return response
|
||||
|
|
|
@ -98,9 +98,7 @@ Requester Bob <requester-bob@example.com> updated [ticket #11](http://test1234zz
|
|||
expected_message = """
|
||||
Requester Bob <requester-bob@example.com> added a {} note to \
|
||||
[ticket #11](http://test1234zzz.freshdesk.com/helpdesk/tickets/11).
|
||||
""".strip().format(
|
||||
note_type
|
||||
)
|
||||
""".strip().format(note_type)
|
||||
self.api_stream_message(
|
||||
self.test_user,
|
||||
fixture,
|
||||
|
|
|
@ -189,7 +189,7 @@ def get_assignees(payload: WildValue) -> Union[List[WildValue], WildValue]:
|
|||
|
||||
|
||||
def replace_assignees_username_with_name(
|
||||
assignees: Union[List[WildValue], WildValue]
|
||||
assignees: Union[List[WildValue], WildValue],
|
||||
) -> List[Dict[str, str]]:
|
||||
"""Replace the username of each assignee with their (full) name.
|
||||
|
||||
|
|
|
@ -164,9 +164,7 @@ def api_librato_webhook(
|
|||
request: HttpRequest,
|
||||
user_profile: UserProfile,
|
||||
*,
|
||||
payload: Json[
|
||||
Mapping[str, Any]
|
||||
] = {}, # noqa: B006 # Mapping is indeed immutable, but Json's type annotation drops that information
|
||||
payload: Json[Mapping[str, Any]] = {}, # noqa: B006 # Mapping is indeed immutable, but Json's type annotation drops that information
|
||||
) -> HttpResponse:
|
||||
try:
|
||||
attachments = orjson.loads(request.body).get("attachments", [])
|
||||
|
|
|
@ -103,7 +103,7 @@ def validate_remote_server(
|
|||
|
||||
|
||||
def authenticated_remote_server_view(
|
||||
view_func: Callable[Concatenate[HttpRequest, RemoteZulipServer, ParamT], HttpResponse]
|
||||
view_func: Callable[Concatenate[HttpRequest, RemoteZulipServer, ParamT], HttpResponse],
|
||||
) -> Callable[Concatenate[HttpRequest, ParamT], HttpResponse]:
|
||||
@wraps(view_func)
|
||||
def _wrapped_view_func(
|
||||
|
|
|
@ -979,8 +979,9 @@ class Command(BaseCommand):
|
|||
"test": {"description": "For testing `code`"},
|
||||
"errors": {"description": "For errors"},
|
||||
# 조리법 - Recipes (Korean), Пельмени - Dumplings (Russian)
|
||||
"조리법 "
|
||||
+ raw_emojis[0]: {"description": "Everything cooking, from pasta to Пельмени"},
|
||||
"조리법 " + raw_emojis[0]: {
|
||||
"description": "Everything cooking, from pasta to Пельмени"
|
||||
},
|
||||
}
|
||||
|
||||
extra_stream_names = [
|
||||
|
@ -1122,7 +1123,7 @@ def get_recipient_by_id(rid: int) -> Recipient:
|
|||
# - multiple messages per subject
|
||||
# - both single and multi-line content
|
||||
def generate_and_send_messages(
|
||||
data: Tuple[int, Sequence[Sequence[int]], Mapping[str, Any], int]
|
||||
data: Tuple[int, Sequence[Sequence[int]], Mapping[str, Any], int],
|
||||
) -> int:
|
||||
realm = get_realm("zulip")
|
||||
(tot_messages, personals_pairs, options, random_seed) = data
|
||||
|
|
|
@ -72,7 +72,9 @@ def do_bulk_backfill_extra_data(
|
|||
old_value = audit_log_entry.extra_data_json # type: ignore[attr-defined] # The migration cannot depend on zerver.models, which contains the real type of the RealmAuditLog model, so it cannot be properly typed.
|
||||
new_value = ast.literal_eval(audit_log_entry.extra_data) # type: ignore[attr-defined] # Explained above.
|
||||
if old_value not in ({}, new_value):
|
||||
inconsistent_extra_data_json.append((audit_log_entry.id, audit_log_entry.extra_data, old_value, new_value)) # type: ignore[attr-defined] # Explained above.
|
||||
inconsistent_extra_data_json.append(
|
||||
(audit_log_entry.id, audit_log_entry.extra_data, old_value, new_value) # type: ignore[attr-defined] # Explained above.
|
||||
)
|
||||
audit_log_entry.extra_data_json = new_value # type: ignore[attr-defined] # Explained above.
|
||||
audit_log_model._default_manager.bulk_update(
|
||||
python_valued_audit_log_entries, fields=["extra_data_json"]
|
||||
|
|
|
@ -4,7 +4,6 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("zilencer", "0057_remoterealm_last_request_timestamp_and_more"),
|
||||
]
|
||||
|
|
|
@ -4,7 +4,6 @@ from django.db import migrations, models
|
|||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("zilencer", "0058_remoteinstallationcount_add_mobile_pushes_forwarded_index"),
|
||||
]
|
||||
|
|
|
@ -552,7 +552,8 @@ def get_remote_realm_guest_and_non_guest_count(
|
|||
# bulk_create_users to create the users in the system bot
|
||||
# realm also generate such audit logs. Such audit logs should
|
||||
# never be the latest in a normal realm.
|
||||
.exclude(extra_data={}).last()
|
||||
.exclude(extra_data={})
|
||||
.last()
|
||||
)
|
||||
|
||||
if latest_audit_log is not None:
|
||||
|
|
Loading…
Reference in New Issue