summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorDavid Robertson <davidr@element.io>2023-02-06 13:10:03 +0000
committerDavid Robertson <davidr@element.io>2023-02-06 14:35:43 +0000
commit2dfccdc1c39a439fd3500895b703a91d549bac78 (patch)
treec4aa09d2913f0ad99e5bf1a2fd3c7f24cc3794a5 /tests
parentDeferredCache.get & .set are fine to not await(?) (diff)
downloadsynapse-2dfccdc1c39a439fd3500895b703a91d549bac78.tar.xz
Ignore other false-positives
Diffstat (limited to 'tests')
-rw-r--r--tests/crypto/test_keyring.py6
-rw-r--r--tests/util/caches/test_descriptors.py6
-rw-r--r--tests/util/test_async_helpers.py16
-rw-r--r--tests/util/test_linearizer.py2
-rw-r--r--tests/util/test_logcontext.py5
-rw-r--r--tests/util/test_ratelimitutils.py2
6 files changed, 21 insertions, 16 deletions
diff --git a/tests/crypto/test_keyring.py b/tests/crypto/test_keyring.py
index 0e8af2da54..56193bc000 100644
--- a/tests/crypto/test_keyring.py
+++ b/tests/crypto/test_keyring.py
@@ -130,7 +130,9 @@ class KeyringTestCase(unittest.HomeserverTestCase):
                     pass
 
                 self.assertFalse(res_deferreds[0].called)
-                res_deferreds[0].addBoth(self.check_context, None)
+                # type-ignore: Deferred.addBoth returns `self`; it doesn't need to be
+                # awaited as long as we use the await the deferred elsewhere
+                res_deferreds[0].addBoth(self.check_context, None)  # type: ignore[unused-awaitable]
 
                 await make_deferred_yieldable(res_deferreds[0])
 
@@ -166,7 +168,7 @@ class KeyringTestCase(unittest.HomeserverTestCase):
                         )
                     ]
                 )
-                res_deferreds_2[0].addBoth(self.check_context, None)
+                res_deferreds_2[0].addBoth(self.check_context, None)  # type: ignore[unused-awaitable]
                 second_lookup_state[0] = 1
                 await make_deferred_yieldable(res_deferreds_2[0])
                 second_lookup_state[0] = 2
diff --git a/tests/util/caches/test_descriptors.py b/tests/util/caches/test_descriptors.py
index 13f1edd533..1cc009aee5 100644
--- a/tests/util/caches/test_descriptors.py
+++ b/tests/util/caches/test_descriptors.py
@@ -292,12 +292,14 @@ class DescriptorTestCase(unittest.TestCase):
         # set off a deferred which will do a cache lookup
         d1 = do_lookup()
         self.assertEqual(current_context(), SENTINEL_CONTEXT)
-        d1.addCallback(check_result)
+        # type-ignore: addCallback returns self, so as long as we await d1 (and d2)
+        # below, this error is a false positive.
+        d1.addCallback(check_result)  # type: ignore[unused-awaitable]
 
         # and another
         d2 = do_lookup()
         self.assertEqual(current_context(), SENTINEL_CONTEXT)
-        d2.addCallback(check_result)
+        d2.addCallback(check_result)  # type: ignore[unused-awaitable]
 
         # let the lookup complete
         complete_lookup.callback(None)
diff --git a/tests/util/test_async_helpers.py b/tests/util/test_async_helpers.py
index 91cac9822a..7730c23e5a 100644
--- a/tests/util/test_async_helpers.py
+++ b/tests/util/test_async_helpers.py
@@ -57,7 +57,7 @@ class ObservableDeferredTest(TestCase):
             self.assertFalse(observer2.called)
             return res
 
-        observer1.addBoth(check_called_first)
+        observer1.addBoth(check_called_first)  # type: ignore[unused-awaitable]
 
         # store the results
         results: List[Optional[ObservableDeferred[int]]] = [None, None]
@@ -68,8 +68,8 @@ class ObservableDeferredTest(TestCase):
             results[idx] = res
             return res
 
-        observer1.addCallback(check_val, 0)
-        observer2.addCallback(check_val, 1)
+        observer1.addCallback(check_val, 0)  # type: ignore[unused-awaitable]
+        observer2.addCallback(check_val, 1)  # type: ignore[unused-awaitable]
 
         origin_d.callback(123)
         self.assertEqual(results[0], 123, "observer 1 callback result")
@@ -90,7 +90,7 @@ class ObservableDeferredTest(TestCase):
             self.assertFalse(observer2.called)
             return res
 
-        observer1.addBoth(check_called_first)
+        observer1.addBoth(check_called_first)  # type: ignore[unused-awaitable]
 
         # store the results
         results: List[Optional[ObservableDeferred[str]]] = [None, None]
@@ -99,8 +99,8 @@ class ObservableDeferredTest(TestCase):
             results[idx] = res
             return None
 
-        observer1.addErrback(check_val, 0)
-        observer2.addErrback(check_val, 1)
+        observer1.addErrback(check_val, 0)  # type: ignore[unused-awaitable]
+        observer2.addErrback(check_val, 1)  # type: ignore[unused-awaitable]
 
         try:
             raise Exception("gah!")
@@ -208,11 +208,11 @@ class TimeoutDeferredTest(TestCase):
                 return res
 
             original_deferred = blocking()
-            original_deferred.addErrback(errback, "orig")
+            original_deferred.addErrback(errback, "orig")  # type: ignore[unused-awaitable]
             timing_out_d = timeout_deferred(original_deferred, 1.0, self.clock)
             self.assertNoResult(timing_out_d)
             self.assertIs(current_context(), SENTINEL_CONTEXT)
-            timing_out_d.addErrback(errback, "timingout")
+            timing_out_d.addErrback(errback, "timingout")  # type: ignore[unused-awaitable]
 
             self.clock.pump((1.0,))
 
diff --git a/tests/util/test_linearizer.py b/tests/util/test_linearizer.py
index 47a1cfbdc1..c8f8f6bce4 100644
--- a/tests/util/test_linearizer.py
+++ b/tests/util/test_linearizer.py
@@ -140,7 +140,7 @@ class LinearizerTestCase(unittest.TestCase):
 
         _, _, unblock = self._start_task(linearizer, key)
         for i in range(1, 100):
-            defer.ensureDeferred(func(i))
+            defer.ensureDeferred(func(i))  # type: ignore[unused-awaitable]
 
         d = defer.ensureDeferred(func(1000))
         unblock()
diff --git a/tests/util/test_logcontext.py b/tests/util/test_logcontext.py
index d64c162e1d..39f1ddb900 100644
--- a/tests/util/test_logcontext.py
+++ b/tests/util/test_logcontext.py
@@ -74,7 +74,8 @@ class LoggingContextTestCase(unittest.TestCase):
                 callback_completed = True
                 return res
 
-            d2.addCallback(cb)
+            # type-ignore: this doesn't create a new Deferred: allCallback returns self.
+            d2.addCallback(cb)  # type: ignore[unused-awaitable]
 
             self._check_test_key("one")
 
@@ -195,5 +196,5 @@ def _chained_deferred_function() -> defer.Deferred:
         reactor.callLater(0, d2.callback, res)
         return d2
 
-    d.addCallback(cb)
+    d.addCallback(cb)  # type: ignore[unused-awaitable]
     return d
diff --git a/tests/util/test_ratelimitutils.py b/tests/util/test_ratelimitutils.py
index fe4961dcf3..045a51c0b0 100644
--- a/tests/util/test_ratelimitutils.py
+++ b/tests/util/test_ratelimitutils.py
@@ -109,7 +109,7 @@ class FederationRateLimiterTestCase(TestCase):
                     await d
 
             for _ in range(1, 100):
-                defer.ensureDeferred(task())
+                defer.ensureDeferred(task())  # type: ignore[unused-awaitable]
 
             last_task = defer.ensureDeferred(task())