ruff: Fix UP007 Use X | Y for type annotations.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2024-07-11 17:30:23 -07:00
committed by Tim Abbott
parent e08a24e47f
commit 531b34cb4c
355 changed files with 2759 additions and 3029 deletions

View File

@@ -1,5 +1,5 @@
from datetime import timedelta
from typing import Iterable, Optional, Union
from typing import Iterable
from django.conf import settings
from django.db import transaction
@@ -214,7 +214,7 @@ def do_change_password(user_profile: UserProfile, password: str, commit: bool =
def do_change_full_name(
user_profile: UserProfile, full_name: str, acting_user: Optional[UserProfile]
user_profile: UserProfile, full_name: str, acting_user: UserProfile | None
) -> None:
old_name = user_profile.full_name
user_profile.full_name = full_name
@@ -243,7 +243,7 @@ def do_change_full_name(
def check_change_full_name(
user_profile: UserProfile, full_name_raw: str, acting_user: Optional[UserProfile]
user_profile: UserProfile, full_name_raw: str, acting_user: UserProfile | None
) -> str:
"""Verifies that the user's proposed full name is valid. The caller
is responsible for checking check permissions. Returns the new
@@ -278,7 +278,7 @@ def check_change_bot_full_name(
@transaction.atomic(durable=True)
def do_change_tos_version(user_profile: UserProfile, tos_version: Optional[str]) -> None:
def do_change_tos_version(user_profile: UserProfile, tos_version: str | None) -> None:
user_profile.tos_version = tos_version
user_profile.save(update_fields=["tos_version"])
event_time = timezone_now()
@@ -377,7 +377,7 @@ def do_change_avatar_fields(
avatar_source: str,
skip_notify: bool = False,
*,
acting_user: Optional[UserProfile],
acting_user: UserProfile | None,
) -> None:
user_profile.avatar_source = avatar_source
user_profile.avatar_version += 1
@@ -396,7 +396,7 @@ def do_change_avatar_fields(
notify_avatar_url_change(user_profile)
def do_delete_avatar_image(user: UserProfile, *, acting_user: Optional[UserProfile]) -> None:
def do_delete_avatar_image(user: UserProfile, *, acting_user: UserProfile | None) -> None:
old_version = user.avatar_version
do_change_avatar_fields(user, UserProfile.AVATAR_FROM_GRAVATAR, acting_user=acting_user)
delete_avatar_image(user, old_version)
@@ -422,9 +422,9 @@ def update_scheduled_email_notifications_time(
def do_change_user_setting(
user_profile: UserProfile,
setting_name: str,
setting_value: Union[bool, str, int],
setting_value: bool | str | int,
*,
acting_user: Optional[UserProfile],
acting_user: UserProfile | None,
) -> None:
old_value = getattr(user_profile, setting_name)
event_time = timezone_now()