mirror of
https://github.com/zulip/zulip.git
synced 2025-11-09 16:37:23 +00:00
models: Fix type annotation with StrPromise.
Signed-off-by: Zixuan James Li <p359101898@gmail.com>
This commit is contained in:
committed by
Tim Abbott
parent
f55ec8a026
commit
ab9279aabe
@@ -1,15 +1,17 @@
|
|||||||
import os
|
import os
|
||||||
from dataclasses import dataclass, field
|
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.contrib.staticfiles.storage import staticfiles_storage
|
||||||
from django.urls import URLResolver, path
|
from django.urls import URLResolver, path
|
||||||
from django.utils.functional import Promise
|
|
||||||
from django.utils.module_loading import import_string
|
from django.utils.module_loading import import_string
|
||||||
from django.utils.translation import gettext_lazy
|
from django.utils.translation import gettext_lazy
|
||||||
|
|
||||||
from zerver.lib.storage import static_path
|
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
|
"""This module declares all of the (documented) integrations available
|
||||||
in the Zulip server. The Integration class is used as part of
|
in the Zulip server. The Integration class is used as part of
|
||||||
generating the documentation on the /integrations page, while the
|
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]]
|
OptionValidator = Callable[[str, str], Optional[str]]
|
||||||
|
|
||||||
CATEGORIES: Dict[str, Promise] = {
|
CATEGORIES: Dict[str, "StrPromise"] = {
|
||||||
"meta-integration": gettext_lazy("Integration frameworks"),
|
"meta-integration": gettext_lazy("Integration frameworks"),
|
||||||
"continuous-integration": gettext_lazy("Continuous integration"),
|
"continuous-integration": gettext_lazy("Continuous integration"),
|
||||||
"customer-support": gettext_lazy("Customer support"),
|
"customer-support": gettext_lazy("Customer support"),
|
||||||
|
|||||||
@@ -46,7 +46,6 @@ from django.db.models.functions import Upper
|
|||||||
from django.db.models.query import QuerySet
|
from django.db.models.query import QuerySet
|
||||||
from django.db.models.signals import post_delete, post_save, pre_delete
|
from django.db.models.signals import post_delete, post_save, pre_delete
|
||||||
from django.db.models.sql.compiler import SQLCompiler
|
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.timezone import now as timezone_now
|
||||||
from django.utils.translation import gettext as _
|
from django.utils.translation import gettext as _
|
||||||
from django.utils.translation import gettext_lazy
|
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.
|
# We use ModelBackend only for typing. Importing it otherwise causes circular dependency.
|
||||||
from django.contrib.auth.backends import ModelBackend
|
from django.contrib.auth.backends import ModelBackend
|
||||||
from django.db.models.query import _QuerySet as ValuesQuerySet
|
from django.db.models.query import _QuerySet as ValuesQuerySet
|
||||||
|
from django.utils.functional import _StrPromise as StrPromise
|
||||||
|
|
||||||
|
|
||||||
class EmojiInfo(TypedDict):
|
class EmojiInfo(TypedDict):
|
||||||
@@ -2452,7 +2452,7 @@ class Stream(models.Model):
|
|||||||
|
|
||||||
# Who in the organization has permission to send messages to this stream.
|
# Who in the organization has permission to send messages to this stream.
|
||||||
stream_post_policy: int = models.PositiveSmallIntegerField(default=STREAM_POST_POLICY_EVERYONE)
|
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
|
# These strings should match the strings in the
|
||||||
# stream_post_policy_values object in stream_data.js.
|
# stream_post_policy_values object in stream_data.js.
|
||||||
STREAM_POST_POLICY_EVERYONE: gettext_lazy("All stream members can post"),
|
STREAM_POST_POLICY_EVERYONE: gettext_lazy("All stream members can post"),
|
||||||
|
|||||||
Reference in New Issue
Block a user