Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

models: Fix type annotation with StrPromise.

Zixuan James Liab9279aabe4b
diff --git a/zerver/lib/integrations.py b/zerver/lib/integrations.py
index 3bf7eed77c5..9a79dc7319e 100644
--- a/zerver/lib/integrations.py
+++ b/zerver/lib/integrations.py
@@ -1,15 +1,17 @@
import os
from dataclasses import dataclass, field
-from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple
+from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, Sequence, Tuple
from django.contrib.staticfiles.storage import staticfiles_storage
from django.urls import URLResolver, path
-from django.utils.functional import Promise
from django.utils.module_loading import import_string
from django.utils.translation import gettext_lazy
from zerver.lib.storage import static_path
+if TYPE_CHECKING:
+ from django.utils.functional import _StrPromise as StrPromise
+
"""This module declares all of the (documented) integrations available
in the Zulip server. The Integration class is used as part of
generating the documentation on the /integrations page, while the
@@ -31,7 +33,7 @@ features for writing and configuring integrations efficiently.
OptionValidator = Callable[[str, str], Optional[str]]
-CATEGORIES: Dict[str, Promise] = {
+CATEGORIES: Dict[str, "StrPromise"] = {
"meta-integration": gettext_lazy("Integration frameworks"),
"continuous-integration": gettext_lazy("Continuous integration"),
"customer-support": gettext_lazy("Customer support"),
diff --git a/zerver/models.py b/zerver/models.py
index ffff63ada36..9fe2ca32029 100644
--- a/zerver/models.py
+++ b/zerver/models.py
@@ -46,7 +46,6 @@ from django.db.models.functions import Upper
from django.db.models.query import QuerySet
from django.db.models.signals import post_delete, post_save, pre_delete
from django.db.models.sql.compiler import SQLCompiler
-from django.utils.functional import Promise
from django.utils.timezone import now as timezone_now
from django.utils.translation import gettext as _
from django.utils.translation import gettext_lazy
@@ -120,6 +119,7 @@ if TYPE_CHECKING:
# We use ModelBackend only for typing. Importing it otherwise causes circular dependency.
from django.contrib.auth.backends import ModelBackend
from django.db.models.query import _QuerySet as ValuesQuerySet
+ from django.utils.functional import _StrPromise as StrPromise
class EmojiInfo(TypedDict):
@@ -2452,7 +2452,7 @@ class Stream(models.Model):
# Who in the organization has permission to send messages to this stream.
stream_post_policy: int = models.PositiveSmallIntegerField(default=STREAM_POST_POLICY_EVERYONE)
- POST_POLICIES: Dict[int, str] = {
+ POST_POLICIES: Dict[int, "StrPromise"] = {
# These strings should match the strings in the
# stream_post_policy_values object in stream_data.js.
STREAM_POST_POLICY_EVERYONE: gettext_lazy("All stream members can post"),