models: Fix type annotation with StrPromise.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
This commit is contained in:
Zixuan James Li
2022-08-05 12:45:43 -04:00
committed by Tim Abbott
parent f55ec8a026
commit ab9279aabe
2 changed files with 7 additions and 5 deletions

View File

@@ -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"),

View File

@@ -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"),