mirror of
				https://github.com/zulip/zulip.git
				synced 2025-11-04 05:53:43 +00:00 
			
		
		
		
	Instead of having the rather unclear type Union[str, List[UserDisplayRecipient]] where display_recipient of message dicts was involved, we use DisplayRecipientT (renamed from DisplayRecipientCacheT - since there wasn't much reason to have the word Cache in there), which makes it clearer what is the actual nature of the objects and gets rid of this pretty big type declaration.
		
			
				
	
	
		
			34 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			34 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
from typing import TypeVar, Callable, Optional, List, Dict, Union, Tuple, Any
 | 
						|
from typing_extensions import TypedDict
 | 
						|
from django.http import HttpResponse
 | 
						|
 | 
						|
ViewFuncT = TypeVar('ViewFuncT', bound=Callable[..., HttpResponse])
 | 
						|
 | 
						|
# See zerver/lib/validator.py for more details of Validators,
 | 
						|
# including many examples
 | 
						|
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?
 | 
						|
ProfileData = List[ProfileDataElement]
 | 
						|
 | 
						|
FieldElement = Tuple[int, str, Validator, Callable[[Any], Any], str]
 | 
						|
ExtendedFieldElement = Tuple[int, str, ExtendedValidator, Callable[[Any], Any], str]
 | 
						|
UserFieldElement = Tuple[int, str, RealmUserValidator, Callable[[Any], Any], str]
 | 
						|
 | 
						|
ProfileFieldData = Dict[str, Union[Dict[str, str], str]]
 | 
						|
 | 
						|
UserDisplayRecipient = TypedDict('UserDisplayRecipient', {'email': str, 'full_name': str, 'short_name': str,
 | 
						|
                                                          'id': int, 'is_mirror_dummy': bool})
 | 
						|
DisplayRecipientT = Union[str, List[UserDisplayRecipient]]
 |