ruff: Fix SIM300 Yoda conditions are discouraged.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2024-01-28 15:52:43 -08:00 committed by Tim Abbott
parent 3dfc24a908
commit ab25ebd5ce
5 changed files with 5 additions and 5 deletions

View File

@ -44,7 +44,7 @@ def upload_emoji(
[emoji_file] = request.FILES.values()
assert isinstance(emoji_file, UploadedFile)
assert emoji_file.size is not None
if (settings.MAX_EMOJI_FILE_SIZE_MIB * 1024 * 1024) < emoji_file.size:
if emoji_file.size > settings.MAX_EMOJI_FILE_SIZE_MIB * 1024 * 1024:
raise JsonableError(
_("Uploaded file is larger than the allowed limit of {max_size} MiB").format(
max_size=settings.MAX_EMOJI_FILE_SIZE_MIB,

View File

@ -22,7 +22,7 @@ def upload_icon(request: HttpRequest, user_profile: UserProfile) -> HttpResponse
[icon_file] = request.FILES.values()
assert isinstance(icon_file, UploadedFile)
assert icon_file.size is not None
if (settings.MAX_ICON_FILE_SIZE_MIB * 1024 * 1024) < icon_file.size:
if icon_file.size > settings.MAX_ICON_FILE_SIZE_MIB * 1024 * 1024:
raise JsonableError(
_("Uploaded file is larger than the allowed limit of {max_size} MiB").format(
max_size=settings.MAX_ICON_FILE_SIZE_MIB,

View File

@ -28,7 +28,7 @@ def upload_logo(
[logo_file] = request.FILES.values()
assert isinstance(logo_file, UploadedFile)
assert logo_file.size is not None
if (settings.MAX_LOGO_FILE_SIZE_MIB * 1024 * 1024) < logo_file.size:
if logo_file.size > settings.MAX_LOGO_FILE_SIZE_MIB * 1024 * 1024:
raise JsonableError(
_("Uploaded file is larger than the allowed limit of {max_size} MiB").format(
max_size=settings.MAX_LOGO_FILE_SIZE_MIB,

View File

@ -315,7 +315,7 @@ def upload_file_backend(request: HttpRequest, user_profile: UserProfile) -> Http
assert isinstance(user_file, UploadedFile)
file_size = user_file.size
assert file_size is not None
if settings.MAX_FILE_UPLOAD_SIZE * 1024 * 1024 < file_size:
if file_size > settings.MAX_FILE_UPLOAD_SIZE * 1024 * 1024:
raise JsonableError(
_("Uploaded file is larger than the allowed limit of {max_size} MiB").format(
max_size=settings.MAX_FILE_UPLOAD_SIZE,

View File

@ -410,7 +410,7 @@ def set_avatar_backend(request: HttpRequest, user_profile: UserProfile) -> HttpR
[user_file] = request.FILES.values()
assert isinstance(user_file, UploadedFile)
assert user_file.size is not None
if (settings.MAX_AVATAR_FILE_SIZE_MIB * 1024 * 1024) < user_file.size:
if user_file.size > settings.MAX_AVATAR_FILE_SIZE_MIB * 1024 * 1024:
raise JsonableError(
_("Uploaded file is larger than the allowed limit of {max_size} MiB").format(
max_size=settings.MAX_AVATAR_FILE_SIZE_MIB,