mirror of
				https://github.com/zulip/zulip.git
				synced 2025-10-30 11:33:51 +00:00 
			
		
		
		
	mypy: Don’t use Iterable for values iterated multiple times.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
		
				
					committed by
					
						 Tim Abbott
						Tim Abbott
					
				
			
			
				
	
			
			
			
						parent
						
							393ffcb318
						
					
				
				
					commit
					871e73ab8f
				
			| @@ -2550,7 +2550,7 @@ def extract_private_recipients(s: str) -> Union[List[str], List[int]]: | ||||
|     return get_validated_user_ids(data) | ||||
|  | ||||
|  | ||||
| def get_validated_user_ids(user_ids: Iterable[int]) -> List[int]: | ||||
| def get_validated_user_ids(user_ids: Collection[int]) -> List[int]: | ||||
|     for user_id in user_ids: | ||||
|         if not isinstance(user_id, int): | ||||
|             raise JsonableError(_("Recipient lists may contain emails or user IDs, but not both.")) | ||||
| @@ -2558,7 +2558,7 @@ def get_validated_user_ids(user_ids: Iterable[int]) -> List[int]: | ||||
|     return list(set(user_ids)) | ||||
|  | ||||
|  | ||||
| def get_validated_emails(emails: Iterable[str]) -> List[str]: | ||||
| def get_validated_emails(emails: Collection[str]) -> List[str]: | ||||
|     for email in emails: | ||||
|         if not isinstance(email, str): | ||||
|             raise JsonableError(_("Recipient lists may contain emails or user IDs, but not both.")) | ||||
| @@ -3216,7 +3216,7 @@ def validate_user_access_to_subscribers_helper( | ||||
|  | ||||
|  | ||||
| def bulk_get_subscriber_user_ids( | ||||
|     stream_dicts: Iterable[Mapping[str, Any]], | ||||
|     stream_dicts: Collection[Mapping[str, Any]], | ||||
|     user_profile: UserProfile, | ||||
|     subscribed_stream_ids: Set[int], | ||||
| ) -> Dict[int, List[int]]: | ||||
| @@ -3348,7 +3348,7 @@ SubT = Tuple[List[SubInfo], List[SubInfo]] | ||||
|  | ||||
| def bulk_add_subscriptions( | ||||
|     realm: Realm, | ||||
|     streams: Iterable[Stream], | ||||
|     streams: Collection[Stream], | ||||
|     users: Iterable[UserProfile], | ||||
|     color_map: Mapping[str, str] = {}, | ||||
|     from_user_creation: bool = False, | ||||
| @@ -6197,7 +6197,7 @@ def get_active_presence_idle_user_ids( | ||||
|  | ||||
|     user_ids = set() | ||||
|     for user_id in active_user_ids: | ||||
|         flags: Iterable[str] = user_flags.get(user_id, []) | ||||
|         flags = user_flags.get(user_id, []) | ||||
|         mentioned = "mentioned" in flags or "wildcard_mentioned" in flags | ||||
|         private_message = is_pm and user_id != sender_id | ||||
|         alerted = "has_alert_word" in flags | ||||
| @@ -6289,7 +6289,7 @@ class InvitationError(JsonableError): | ||||
|         self.sent_invitations: bool = sent_invitations | ||||
|  | ||||
|  | ||||
| def estimate_recent_invites(realms: Iterable[Realm], *, days: int) -> int: | ||||
| def estimate_recent_invites(realms: Collection[Realm], *, days: int) -> int: | ||||
|     """An upper bound on the number of invites sent in the last `days` days""" | ||||
|     recent_invites = RealmCount.objects.filter( | ||||
|         realm__in=realms, | ||||
| @@ -6342,7 +6342,7 @@ def check_invite_limit(realm: Realm, num_invitees: int) -> None: | ||||
| def do_invite_users( | ||||
|     user_profile: UserProfile, | ||||
|     invitee_emails: Collection[str], | ||||
|     streams: Iterable[Stream], | ||||
|     streams: Collection[Stream], | ||||
|     invite_as: int = PreregistrationUser.INVITE_AS["MEMBER"], | ||||
| ) -> None: | ||||
|  | ||||
| @@ -6597,7 +6597,7 @@ def do_remove_realm_emoji(realm: Realm, name: str) -> None: | ||||
|     notify_realm_emoji(realm) | ||||
|  | ||||
|  | ||||
| def notify_alert_words(user_profile: UserProfile, words: Iterable[str]) -> None: | ||||
| def notify_alert_words(user_profile: UserProfile, words: Sequence[str]) -> None: | ||||
|     event = dict(type="alert_words", alert_words=words) | ||||
|     send_event(user_profile.realm, event, [user_profile.id]) | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user