typing: Import StrPromise alias from django_stubs_ext.

This saves us from using a conditional import.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
This commit is contained in:
Zixuan James Li
2022-09-19 15:43:34 -04:00
committed by Tim Abbott
parent df18bbbd48
commit a4eaa770f0
6 changed files with 23 additions and 45 deletions

View File

@@ -1,23 +1,10 @@
import datetime
from dataclasses import dataclass
from typing import (
TYPE_CHECKING,
Any,
Callable,
Dict,
List,
Optional,
Tuple,
TypedDict,
TypeVar,
Union,
)
from typing import Any, Callable, Dict, List, Optional, Tuple, TypedDict, TypeVar, Union
from django_stubs_ext import StrPromise
from typing_extensions import NotRequired
if TYPE_CHECKING:
from django.utils.functional import _StrPromise as StrPromise
# See zerver/lib/validator.py for more details of Validators,
# including many examples
ResultT = TypeVar("ResultT")
@@ -51,11 +38,9 @@ class ProfileDataElementUpdateDict(TypedDict):
ProfileData = List[ProfileDataElement]
FieldElement = Tuple[
int, "StrPromise", Validator[ProfileDataElementValue], Callable[[Any], Any], str
]
ExtendedFieldElement = Tuple[int, "StrPromise", ExtendedValidator, Callable[[Any], Any], str]
UserFieldElement = Tuple[int, "StrPromise", RealmUserValidator, Callable[[Any], Any], str]
FieldElement = Tuple[int, StrPromise, Validator[ProfileDataElementValue], Callable[[Any], Any], str]
ExtendedFieldElement = Tuple[int, StrPromise, ExtendedValidator, Callable[[Any], Any], str]
UserFieldElement = Tuple[int, StrPromise, RealmUserValidator, Callable[[Any], Any], str]
ProfileFieldData = Dict[str, Union[Dict[str, str], str]]