summary refs log tree commit diff
diff options
context:
space:
mode:
authorOlivier 'reivilibre <oliverw@matrix.org>2024-07-30 14:54:42 +0100
committerOlivier 'reivilibre <oliverw@matrix.org>2024-07-30 14:54:42 +0100
commita301c634268947732ff19aa165373dcb2e28a4d7 (patch)
tree6455febe8121f5a94b0501346052a434a6c6c867
parentNewsfile (diff)
downloadsynapse-a301c634268947732ff19aa165373dcb2e28a4d7.tar.xz
Fix and hush Mypy errors
-rw-r--r--synapse/http/proxy.py2
-rw-r--r--synapse/http/server.py4
-rw-r--r--synapse/http/site.py2
-rw-r--r--tests/rest/client/test_login.py2
4 files changed, 6 insertions, 4 deletions
diff --git a/synapse/http/proxy.py b/synapse/http/proxy.py
index 04d8b519fe..97aa429e7d 100644
--- a/synapse/http/proxy.py
+++ b/synapse/http/proxy.py
@@ -64,7 +64,7 @@ HOP_BY_HOP_HEADERS = {
 
 if hasattr(Headers, "_canonicalNameCaps"):
     # Twisted < 24.7.0rc1
-    _canonicalHeaderName = Headers()._canonicalNameCaps
+    _canonicalHeaderName = Headers()._canonicalNameCaps  # type: ignore[attr-defined]
 else:
     # Twisted >= 24.7.0rc1
     # But note that `_encodeName` still exists on prior versions,
diff --git a/synapse/http/server.py b/synapse/http/server.py
index 211795dc39..0d0c610b28 100644
--- a/synapse/http/server.py
+++ b/synapse/http/server.py
@@ -74,6 +74,7 @@ from synapse.api.errors import (
 from synapse.config.homeserver import HomeServerConfig
 from synapse.logging.context import defer_to_thread, preserve_fn, run_in_background
 from synapse.logging.opentracing import active_span, start_active_span, trace_servlet
+from synapse.types import ISynapseReactor
 from synapse.util import json_encoder
 from synapse.util.caches import intern_dict
 from synapse.util.cancellation import is_function_cancellable
@@ -868,7 +869,8 @@ async def _async_write_json_to_request_in_thread(
 
     with start_active_span("encode_json_response"):
         span = active_span()
-        json_str = await defer_to_thread(request.reactor, encode, span)
+        reactor: ISynapseReactor = request.reactor  # type: ignore
+        json_str = await defer_to_thread(reactor, encode, span)
 
     _write_bytes_to_request(request, json_str)
 
diff --git a/synapse/http/site.py b/synapse/http/site.py
index a5b5780679..af169ba51e 100644
--- a/synapse/http/site.py
+++ b/synapse/http/site.py
@@ -683,7 +683,7 @@ class SynapseSite(ProxySite):
         self.access_logger = logging.getLogger(logger_name)
         self.server_version_string = server_version_string.encode("ascii")
 
-    def log(self, request: SynapseRequest) -> None:
+    def log(self, request: SynapseRequest) -> None:  # type: ignore[override]
         pass
 
 
diff --git a/tests/rest/client/test_login.py b/tests/rest/client/test_login.py
index 3a99838719..2b1e44381b 100644
--- a/tests/rest/client/test_login.py
+++ b/tests/rest/client/test_login.py
@@ -969,7 +969,7 @@ class CASTestCase(unittest.HomeserverTestCase):
         # Test that the response is HTML.
         self.assertEqual(channel.code, 200, channel.result)
         content_type_header_value = ""
-        for header in channel.headers.getRawHeaders("Content-Type"):
+        for header in channel.headers.getRawHeaders("Content-Type", []):
             content_type_header_value = header
 
         self.assertTrue(content_type_header_value.startswith("text/html"))