Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
ruff: Fix RUF036 `None` not at the end of the type union.
Anders Kaseorge8cdc5231968
diff --git a/confirmation/models.py b/confirmation/models.pyindex 841d3ae7d2e..6be6728c636 100644--- a/confirmation/models.py+++ b/confirmation/models.py@@ -140,7 +140,7 @@ def create_confirmation_object(obj: ConfirmationObjT,confirmation_type: int,*,- validity_in_minutes: int | None | Unset = UNSET,+ validity_in_minutes: int | Unset | None = UNSET,no_associated_realm_object: bool = False,) -> "Confirmation":# validity_in_minutes is an override for the default values which are@@ -183,7 +183,7 @@ def create_confirmation_link(obj: ConfirmationObjT,confirmation_type: int,*,- validity_in_minutes: int | None | Unset = UNSET,+ validity_in_minutes: int | Unset | None = UNSET,url_args: Mapping[str, str] = {},no_associated_realm_object: bool = False,) -> str:diff --git a/tools/run-dev b/tools/run-devindex 87eb1f59cbc..b894cc301b1 100755--- a/tools/run-dev+++ b/tools/run-dev@@ -264,7 +264,7 @@ SKIP_AUTO_HEADERS = {async def forward(upstream_port: int, request: web.Request) -> web.StreamResponse:- upstream_response: None | aiohttp.ClientResponse = None+ upstream_response: aiohttp.ClientResponse | None = Nonerequest_started = time.time()while upstream_response is None:try:diff --git a/zerver/data_import/microsoft_teams.py b/zerver/data_import/microsoft_teams.pyindex a2b5480e68b..722c575dfc9 100644--- a/zerver/data_import/microsoft_teams.py+++ b/zerver/data_import/microsoft_teams.py@@ -571,7 +571,7 @@ def process_hosted_content_attachments(def process_messages(added_teams: dict[str, TeamMetadata],- channel_metadata: None | dict[str, ChannelMetadata],+ channel_metadata: dict[str, ChannelMetadata] | None,do_download_and_export_upload_file: Callable[[ExportMessageAttachmentParameter], None],domain_name: str,messages: list[MicrosoftTeamsFieldsT],diff --git a/zerver/data_import/rocketchat.py b/zerver/data_import/rocketchat.pyindex 6540852020f..b7ee0999560 100644--- a/zerver/data_import/rocketchat.py+++ b/zerver/data_import/rocketchat.py@@ -498,7 +498,7 @@ def process_message_attachment(user_id: int,zerver_attachment: list[AttachmentRecordData],uploads_list: list[UploadRecordData],- attachment_lookup: Callable[[str], None | tuple[dict[str, Any], Iterator[bytes]]],+ attachment_lookup: Callable[[str], tuple[dict[str, Any], Iterator[bytes]] | None],output_dir: str,) -> tuple[str, bool]:attachment_data = attachment_lookup(upload["_id"])@@ -582,7 +582,7 @@ def process_raw_message_batch(total_reactions: list[ZerverFieldsT],uploads_list: list[UploadRecordData],zerver_attachment: list[AttachmentRecordData],- attachment_lookup: Callable[[str], None | tuple[dict[str, Any], Iterator[bytes]]],+ attachment_lookup: Callable[[str], tuple[dict[str, Any], Iterator[bytes]] | None],) -> None:def fix_mentions(content: str, mention_user_ids: set[int], rc_channel_mention_data: list[dict[str, str]]@@ -739,7 +739,7 @@ def process_messages(total_reactions: list[ZerverFieldsT],uploads_list: list[UploadRecordData],zerver_attachment: list[AttachmentRecordData],- attachment_lookup: Callable[[str], None | tuple[dict[str, Any], Iterator[bytes]]],+ attachment_lookup: Callable[[str], tuple[dict[str, Any], Iterator[bytes]] | None],output_dir: str,) -> None:private_channels_set = {@@ -1240,7 +1240,7 @@ def do_convert_data(rocketchat_data_dir: str, output_dir: str) -> None:chunk_index = _build_chunk_index(chunks_fh)- def attachment_lookup(file_id: str) -> None | tuple[dict[str, Any], Iterator[bytes]]:+ def attachment_lookup(file_id: str) -> tuple[dict[str, Any], Iterator[bytes]] | None:if file_id not in upload_index: # nocoveragereturn Nonediff --git a/zerver/lib/markdown/__init__.py b/zerver/lib/markdown/__init__.pyindex 3ef5bab37e5..cae847166c3 100644--- a/zerver/lib/markdown/__init__.py+++ b/zerver/lib/markdown/__init__.py@@ -1966,7 +1966,7 @@ class LinkInlineProcessor(markdown.inlinepatterns.LinkInlineProcessor):super().__init__(pattern, zmd)self.zmd = zmd- def zulip_specific_link_changes(self, el: Element) -> None | Element:+ def zulip_specific_link_changes(self, el: Element) -> Element | None:href = el.get("href")assert href is not None@@ -2024,7 +2024,7 @@ class AudioInlineProcessor(markdown.inlinepatterns.LinkInlineProcessor):return self.zulip_specific_src_changes(el)- def zulip_specific_src_changes(self, el: Element) -> None | Element:+ def zulip_specific_src_changes(self, el: Element) -> Element | None:src = el.get("src")assert src is not None@@ -2090,7 +2090,7 @@ class ImageInlineProcessor(markdown.inlinepatterns.ImageInlineProcessor):super().__init__(pattern, zmd)self.zmd = zmd- def zulip_specific_src_changes(self, img: Element) -> None | Element:+ def zulip_specific_src_changes(self, img: Element) -> Element | None:# function partially copied from LinkInlineProcessor.zulip_specific_link_changessrc = img.get("src")assert src is not Nonediff --git a/zerver/lib/remote_server.py b/zerver/lib/remote_server.pyindex c27078c5f39..c24b63b6304 100644--- a/zerver/lib/remote_server.py+++ b/zerver/lib/remote_server.py@@ -125,7 +125,7 @@ class UserDataForRemoteBilling(BaseModel):def send_to_push_bouncer(method: str,endpoint: str,- post_data: bytes | Mapping[str, str | int | None | bytes],+ post_data: bytes | Mapping[str, str | int | bytes | None],extra_headers: Mapping[str, str] = {},) -> dict[str, object]:"""While it does actually send the notice, this function has a lot ofdiff --git a/zerver/lib/upload/__init__.py b/zerver/lib/upload/__init__.pyindex 58238974db8..a486497bc6b 100644--- a/zerver/lib/upload/__init__.py+++ b/zerver/lib/upload/__init__.py@@ -345,7 +345,7 @@ def delete_message_attachments(delete_from: tuple[type[ImageAttachment | Attachment | ArchivedAttachment], ...] = (),) -> Iterator[Callable[[str], None]]:if delete_from == ():- flush_path_ids: None | Callable[[list[str]], None] = None+ flush_path_ids: Callable[[list[str]], None] | None = Noneelse:def delete_from_database(path_ids: list[str]) -> None:diff --git a/zerver/lib/upload/base.py b/zerver/lib/upload/base.pyindex 781bd724e53..a550cda8134 100644--- a/zerver/lib/upload/base.py+++ b/zerver/lib/upload/base.py@@ -65,7 +65,7 @@ class ZulipUploadBackend:self,*,raw_paths: bool = False,- flush: None | Callable[[list[str]], None] = None,+ flush: Callable[[list[str]], None] | None = None,) -> Iterator[Callable[[str], None]]:def delete_one(path_id: str) -> None:self.delete_message_attachment_from_storage(path_id, raw_path=raw_paths)diff --git a/zerver/lib/upload/s3.py b/zerver/lib/upload/s3.pyindex 37073aa6313..440fd667cc1 100644--- a/zerver/lib/upload/s3.py+++ b/zerver/lib/upload/s3.py@@ -297,7 +297,7 @@ class S3UploadBackend(ZulipUploadBackend):@contextmanager@overridedef delete_message_attachments_from_storage(- self, *, raw_paths: bool = False, flush: None | Callable[[list[str]], None] = None+ self, *, raw_paths: bool = False, flush: Callable[[list[str]], None] | None = None) -> Iterator[Callable[[str], None]]:paths: list[tuple[str, bool]] = []diff --git a/zerver/lib/webhooks/common.py b/zerver/lib/webhooks/common.pyindex f2bfa6f7bc2..ac2d8ba7e7a 100644--- a/zerver/lib/webhooks/common.py+++ b/zerver/lib/webhooks/common.py@@ -217,7 +217,7 @@ def check_send_webhook_message(return None-def standardize_headers(input_headers: None | dict[str, Any]) -> dict[str, str]:+def standardize_headers(input_headers: dict[str, Any] | None) -> dict[str, str]:"""This method can be used to standardize a dictionary of headers withthe standard format that Django expects. For reference, refer to:https://docs.djangoproject.com/en/5.0/ref/request-response/#django.http.HttpRequest.headersdiff --git a/zerver/management/commands/send_webhook_fixture_message.py b/zerver/management/commands/send_webhook_fixture_message.pyindex 16bad2a1ce3..de4a7094253 100644--- a/zerver/management/commands/send_webhook_fixture_message.py+++ b/zerver/management/commands/send_webhook_fixture_message.py@@ -51,7 +51,7 @@ approach shown above.parser, help="Specify which realm/subdomain to connect to; default is zulip")- def parse_headers(self, custom_headers: None | str) -> None | dict[str, str]:+ def parse_headers(self, custom_headers: str | None) -> dict[str, str] | None:if not custom_headers:return {}try:diff --git a/zerver/tests/test_users.py b/zerver/tests/test_users.pyindex 59fc67dcf7c..128aecbc448 100644--- a/zerver/tests/test_users.py+++ b/zerver/tests/test_users.py@@ -999,7 +999,7 @@ class PermissionTest(ZulipTestCase):empty_profile_data = []for field_name in fields:field = CustomProfileField.objects.get(name=field_name, realm=realm)- value: str | None | list[Any] = ""+ value: str | list[Any] | None = ""if field.field_type == CustomProfileField.USER:value = []empty_profile_data.append(diff --git a/zerver/tests/test_zilencer_analytics.py b/zerver/tests/test_zilencer_analytics.pyindex f9a6afd15c1..7fc3d7faa18 100644--- a/zerver/tests/test_zilencer_analytics.py+++ b/zerver/tests/test_zilencer_analytics.py@@ -975,7 +975,7 @@ class AnalyticsBouncerTest(BouncerTestCase):def transform_realmauditlog_extra_data(method: str,endpoint: str,- post_data: bytes | Mapping[str, str | int | None | bytes],+ post_data: bytes | Mapping[str, str | int | bytes | None],extra_headers: Mapping[str, str] = {},) -> dict[str, Any]:if endpoint == "server/analytics":diff --git a/zerver/tornado/django_api.py b/zerver/tornado/django_api.pyindex f30f7ae9230..156748b235c 100644--- a/zerver/tornado/django_api.py+++ b/zerver/tornado/django_api.py@@ -40,9 +40,9 @@ class TornadoAdapter(HTTPAdapter):self,request: PreparedRequest,stream: bool = False,- timeout: None | float | tuple[float, float] | tuple[float, None] = 0.5,+ timeout: float | tuple[float, float] | tuple[float, None] | None = 0.5,verify: bool | str = True,- cert: None | bytes | str | tuple[bytes | str, bytes | str] = None,+ cert: bytes | str | tuple[bytes | str, bytes | str] | None = None,proxies: Mapping[str, str] | None = None,) -> Response:# Don't talk to Tornado through proxies, which only allow