mirror of
https://github.com/zulip/zulip.git
synced 2025-11-02 21:13:36 +00:00
types: Fix declared type of custom profile field values.
None of the existing custom profile field types have the value as an integer like declared in many places - nor is it a string like currently decalred in types.py. The correct type is Union[str, List[int]]. Rather than tracking this in so many places throughout the codebase, we add a new ProfileDataElementValue type and insert it where appropriate.
This commit is contained in:
committed by
Tim Abbott
parent
91ea21a3fc
commit
cacff28578
@@ -76,6 +76,7 @@ from zerver.lib.types import (
|
||||
LinkifierDict,
|
||||
ProfileData,
|
||||
ProfileDataElementBase,
|
||||
ProfileDataElementValue,
|
||||
RealmUserValidator,
|
||||
UserFieldElement,
|
||||
Validator,
|
||||
@@ -3904,7 +3905,7 @@ class CustomProfileField(models.Model):
|
||||
|
||||
ALL_FIELD_TYPES = [*FIELD_TYPE_DATA, *SELECT_FIELD_TYPE_DATA, *USER_FIELD_TYPE_DATA]
|
||||
|
||||
FIELD_VALIDATORS: Dict[int, Validator[Union[int, str, List[int]]]] = {
|
||||
FIELD_VALIDATORS: Dict[int, Validator[ProfileDataElementValue]] = {
|
||||
item[0]: item[2] for item in FIELD_TYPE_DATA
|
||||
}
|
||||
FIELD_CONVERTERS: Dict[int, Callable[[Any], Any]] = {
|
||||
|
||||
Reference in New Issue
Block a user