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

@@ -6,7 +6,6 @@ import traceback
from contextlib import suppress
from datetime import datetime, timedelta, timezone
from logging import Logger
from typing import Optional, Union
import orjson
from django.conf import settings
@@ -120,7 +119,7 @@ class RequireReallyDeployed(logging.Filter):
return settings.PRODUCTION
def find_log_caller_module(record: logging.LogRecord) -> Optional[str]:
def find_log_caller_module(record: logging.LogRecord) -> str | None:
"""Find the module name corresponding to where this record was logged.
Sadly `record.module` is just the innermost component of the full
@@ -224,7 +223,7 @@ class ZulipWebhookFormatter(ZulipFormatter):
@override
def format(self, record: logging.LogRecord) -> str:
request: Optional[HttpRequest] = getattr(record, "request", None)
request: HttpRequest | None = getattr(record, "request", None)
if request is None:
record.user = None
record.client = None
@@ -235,7 +234,7 @@ class ZulipWebhookFormatter(ZulipFormatter):
return super().format(record)
if request.content_type == "application/json":
payload: Union[str, bytes] = request.body
payload: str | bytes = request.body
else:
payload = request.POST["payload"]