Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
ruff: Fix N813 camelcase imported as lowercase.
Anders Kaseorg924d53029264
diff --git a/analytics/views/activity_common.py b/analytics/views/activity_common.pyindex 675578d661e..e8bde1ead99 100644--- a/analytics/views/activity_common.py+++ b/analytics/views/activity_common.py@@ -8,7 +8,7 @@ from django.conf import settingsfrom django.db.backends.utils import CursorWrapperfrom django.template import loaderfrom django.urls import reverse-from markupsafe import Markup as mark_safe+from markupsafe import Markupfrom zerver.models import UserActivity@@ -58,36 +58,36 @@ def format_date_for_activity_reports(date: Optional[datetime]) -> str:return ""-def user_activity_link(email: str, user_profile_id: int) -> mark_safe:+def user_activity_link(email: str, user_profile_id: int) -> Markup:from analytics.views.user_activity import get_user_activityurl = reverse(get_user_activity, kwargs=dict(user_profile_id=user_profile_id))email_link = f'<a href="{escape(url)}">{escape(email)}</a>'- return mark_safe(email_link)+ return Markup(email_link)-def realm_activity_link(realm_str: str) -> mark_safe:+def realm_activity_link(realm_str: str) -> Markup:from analytics.views.realm_activity import get_realm_activityurl = reverse(get_realm_activity, kwargs=dict(realm_str=realm_str))realm_link = f'<a href="{escape(url)}">{escape(realm_str)}</a>'- return mark_safe(realm_link)+ return Markup(realm_link)-def realm_stats_link(realm_str: str) -> mark_safe:+def realm_stats_link(realm_str: str) -> Markup:from analytics.views.stats import stats_for_realmurl = reverse(stats_for_realm, kwargs=dict(realm_str=realm_str))stats_link = f'<a href="{escape(url)}"><i class="fa fa-pie-chart"></i>{escape(realm_str)}</a>'- return mark_safe(stats_link)+ return Markup(stats_link)-def remote_installation_stats_link(server_id: int, hostname: str) -> mark_safe:+def remote_installation_stats_link(server_id: int, hostname: str) -> Markup:from analytics.views.stats import stats_for_remote_installationurl = reverse(stats_for_remote_installation, kwargs=dict(remote_server_id=server_id))stats_link = f'<a href="{escape(url)}"><i class="fa fa-pie-chart"></i>{escape(hostname)}</a>'- return mark_safe(stats_link)+ return Markup(stats_link)def get_user_activity_summary(records: Collection[UserActivity]) -> Dict[str, Any]:diff --git a/analytics/views/installation_activity.py b/analytics/views/installation_activity.pyindex aefba2623ca..05914c23ed4 100644--- a/analytics/views/installation_activity.py+++ b/analytics/views/installation_activity.py@@ -10,7 +10,7 @@ from django.http import HttpRequest, HttpResponsefrom django.shortcuts import renderfrom django.template import loaderfrom django.utils.timezone import now as timezone_now-from markupsafe import Markup as mark_safe+from markupsafe import Markupfrom psycopg2.sql import SQL, Composable, Literalfrom analytics.lib.counts import COUNT_STATS@@ -305,7 +305,7 @@ def realm_summary_table(realm_minutes: Dict[str, float]) -> str:return content-def user_activity_intervals() -> Tuple[mark_safe, Dict[str, float]]:+def user_activity_intervals() -> Tuple[Markup, Dict[str, float]]:day_end = timestamp_to_datetime(time.time())day_start = day_end - timedelta(hours=24)@@ -357,7 +357,7 @@ def user_activity_intervals() -> Tuple[mark_safe, Dict[str, float]]:output += f"\nTotal duration: {total_duration}\n"output += f"\nTotal duration in minutes: {total_duration.total_seconds() / 60.}\n"output += f"Total duration amortized to a month: {total_duration.total_seconds() * 30. / 60.}"- content = mark_safe("<pre>" + output + "</pre>")+ content = Markup("<pre>" + output + "</pre>")return content, realm_minutes@@ -372,7 +372,7 @@ def ad_hoc_queries() -> List[Dict[str, str]]:cursor.close()def fix_rows(- i: int, fixup_func: Union[Callable[[str], mark_safe], Callable[[datetime], str]]+ i: int, fixup_func: Union[Callable[[str], Markup], Callable[[datetime], str]]) -> None:for row in rows:row[i] = fixup_func(row[i])diff --git a/zerver/forms.py b/zerver/forms.pyindex f866375d6d0..868164d3236 100644--- a/zerver/forms.py+++ b/zerver/forms.py@@ -18,7 +18,7 @@ from django.utils.http import urlsafe_base64_encodefrom django.utils.translation import get_languagefrom django.utils.translation import gettext as _from django.utils.translation import gettext_lazy-from markupsafe import Markup as mark_safe+from markupsafe import Markupfrom two_factor.forms import AuthenticationTokenForm as TwoFactorAuthenticationTokenFormfrom two_factor.utils import totp_digits@@ -75,9 +75,9 @@ def email_is_not_mit_mailing_list(email: str) -> None:DNS.dnslookup(f"{address.username}.pobox.ns.athena.mit.edu", DNS.Type.TXT)except DNS.Base.ServerError as e:if e.rcode == DNS.Status.NXDOMAIN:- # This error is mark_safe only because 1. it needs to render HTML+ # This error is Markup only because 1. it needs to render HTML# 2. It's not formatted with any user input.- raise ValidationError(mark_safe(MIT_VALIDATION_ERROR))+ raise ValidationError(Markup(MIT_VALIDATION_ERROR))else:raise AssertionError("Unexpected DNS error")diff --git a/zerver/lib/markdown/__init__.py b/zerver/lib/markdown/__init__.pyindex d51af110b4e..c35b0582c35 100644--- a/zerver/lib/markdown/__init__.py+++ b/zerver/lib/markdown/__init__.py@@ -26,7 +26,6 @@ from typing import (Union,)from urllib.parse import urlencode, urljoin, urlsplit-from xml.etree import ElementTree as etreefrom xml.etree.ElementTree import Element, SubElementimport ahocorasick@@ -1713,7 +1712,7 @@ class BlockQuoteProcessor(markdown.blockprocessors.BlockQuoteProcessor):# a blank line intentionally.## This is a new blockquote. Create a new parent element.- quote = etree.SubElement(parent, "blockquote")+ quote = SubElement(parent, "blockquote")# Recursively parse block with blockquote as parent.# change parser state so blockquotes embedded in lists use p tagsdiff --git a/zerver/lib/upload.py b/zerver/lib/upload.pyindex e732c0e54e7..df6585dc6e0 100644--- a/zerver/lib/upload.py+++ b/zerver/lib/upload.py@@ -23,7 +23,7 @@ from django.core.files.uploadedfile import UploadedFilefrom django.core.signing import BadSignature, TimestampSignerfrom django.urls import reversefrom django.utils.translation import gettext as _-from markupsafe import Markup as mark_safe+from markupsafe import Markupfrom mypy_boto3_s3.client import S3Clientfrom mypy_boto3_s3.service_resource import Bucket, Objectfrom PIL import GifImagePlugin, Image, ImageOps, PngImagePlugin@@ -112,7 +112,7 @@ def sanitize_name(value: str) -> str:value = re.sub(r"[^\w\s.-]", "", value).strip()value = re.sub(r"[-\s]+", "-", value)assert value not in {"", ".", ".."}- return mark_safe(value)+ return Markup(value)class BadImageError(JsonableError):diff --git a/zerver/views/auth.py b/zerver/views/auth.pyindex 12f2778464e..8d0668f0931 100644--- a/zerver/views/auth.py+++ b/zerver/views/auth.py@@ -25,7 +25,7 @@ from django.utils.http import url_has_allowed_host_and_schemefrom django.utils.translation import gettext as _from django.views.decorators.csrf import csrf_exemptfrom django.views.decorators.http import require_safe-from markupsafe import Markup as mark_safe+from markupsafe import Markupfrom social_django.utils import load_backend, load_strategyfrom two_factor.forms import BackupTokenFormfrom two_factor.views import LoginView as BaseTwoFactorLoginView@@ -718,7 +718,7 @@ def update_login_page_context(request: HttpRequest, context: Dict[str, Any]) ->returntry:validate_email(deactivated_email)- context["deactivated_account_error"] = mark_safe(+ context["deactivated_account_error"] = Markup(DEACTIVATED_ACCOUNT_ERROR.format(username=escape(deactivated_email)))except ValidationError: