mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 14:03:30 +00:00
types: Convert ProfileDataElement to Python 3.6 style and total.
The Python 3.6 style does support non-total and even partially-total TypedDict, but total gives us better guarantees. Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
686ae3eef4
commit
46d0018fbb
@@ -11,16 +11,18 @@ Validator = Callable[[str, object], Optional[str]]
|
||||
ExtendedValidator = Callable[[str, str, object], Optional[str]]
|
||||
RealmUserValidator = Callable[[int, List[int], bool], Optional[str]]
|
||||
|
||||
ProfileDataElement = TypedDict('ProfileDataElement', {
|
||||
'id': int,
|
||||
'name': str,
|
||||
'type': int,
|
||||
'hint': Optional[str],
|
||||
'field_data': Optional[str],
|
||||
'order': int,
|
||||
'value': str,
|
||||
'rendered_value': Optional[str],
|
||||
}, total=False) # TODO: Can we remove this requirement?
|
||||
class ProfileDataElementBase(TypedDict):
|
||||
id: int
|
||||
name: str
|
||||
type: int
|
||||
hint: Optional[str]
|
||||
field_data: Optional[str]
|
||||
order: int
|
||||
|
||||
class ProfileDataElement(ProfileDataElementBase):
|
||||
value: str
|
||||
rendered_value: Optional[str]
|
||||
|
||||
ProfileData = List[ProfileDataElement]
|
||||
|
||||
FieldElement = Tuple[int, str, Validator, Callable[[Any], Any], str]
|
||||
|
||||
Reference in New Issue
Block a user