From e361978637e41de0b09023e67127cb052a72b8dc Mon Sep 17 00:00:00 2001 From: Half-Shot Date: Fri, 13 Feb 2026 11:56:48 +0000 Subject: [PATCH] mypy fix --- tests/handlers/test_appservice.py | 4 +++- tests/media/test_url_previewer.py | 11 +++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/tests/handlers/test_appservice.py b/tests/handlers/test_appservice.py index 993d7ae6b5..4dafe4d2d4 100644 --- a/tests/handlers/test_appservice.py +++ b/tests/handlers/test_appservice.py @@ -499,7 +499,9 @@ class AppServiceHandlerTestCase(unittest.TestCase): service.url = "mock_service_url" return service - def _mkservice_url_preview(self, is_in_namespace=True, is_exclusive=False) -> Mock: + def _mkservice_url_preview( + self, is_in_namespace: bool = True, is_exclusive: bool = False + ) -> Mock: """ Create a new mock representing an ApplicationService that is or is not interested in any preview urls. diff --git a/tests/media/test_url_previewer.py b/tests/media/test_url_previewer.py index 1dddacda94..23cf49377d 100644 --- a/tests/media/test_url_previewer.py +++ b/tests/media/test_url_previewer.py @@ -130,7 +130,8 @@ class URLPreviewTests(unittest.HomeserverTestCase): """ Tests that previews fail if the appservice returns an empty response and is exclusive. """ - query_preview_url = self.url_previewer.as_services.query_preview_url = ( + # We assign to a method, which mypy doesn't like. + query_preview_url = self.url_previewer.as_services.query_preview_url = ( # type: ignore[method-assign] AsyncMock() ) query_preview_url.return_value = ApplicationServiceUrlPreviewResult( @@ -147,7 +148,8 @@ class URLPreviewTests(unittest.HomeserverTestCase): """ Tests that previews succeed with an appservice provided result. """ - query_preview_url = self.url_previewer.as_services.query_preview_url = ( + # We assign to a method, which mypy doesn't like. + query_preview_url = self.url_previewer.as_services.query_preview_url = ( # type: ignore[method-assign] AsyncMock() ) query_preview_url.return_value = ApplicationServiceUrlPreviewResult( @@ -166,9 +168,10 @@ class URLPreviewTests(unittest.HomeserverTestCase): """ Tests that previews fall through to the homeserver when the empty result is non-exclusive. """ - do_preview_mock = self.url_previewer._do_preview = AsyncMock() + # We assign to a method, which mypy doesn't like. + do_preview_mock = self.url_previewer._do_preview = AsyncMock() # type: ignore[method-assign] do_preview_mock.return_value = b"HS provided bytes" - query_preview_url = self.url_previewer.as_services.query_preview_url = ( + query_preview_url = self.url_previewer.as_services.query_preview_url = ( # type: ignore[method-assign] AsyncMock() ) query_preview_url.return_value = ApplicationServiceUrlPreviewResult(