Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 4b23950

Browse files
committed
Add None return types.
1 parent 4b3308c commit 4b23950

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

Diff for: tests/util/caches/test_descriptors.py

+18-18
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class DescriptorTestCase(unittest.TestCase):
4747
@defer.inlineCallbacks
4848
def test_cache(self):
4949
class Cls:
50-
def __init__(self):
50+
def __init__(self) -> None:
5151
self.mock = mock.Mock()
5252

5353
@descriptors.cached()
@@ -81,7 +81,7 @@ def test_cache_num_args(self):
8181
"""Only the first num_args arguments should matter to the cache"""
8282

8383
class Cls:
84-
def __init__(self):
84+
def __init__(self) -> None:
8585
self.mock = mock.Mock()
8686

8787
@descriptors.cached(num_args=1)
@@ -126,7 +126,7 @@ class Cls:
126126
def fn(self, arg1, arg2, arg3):
127127
return self.mock(arg1, arg2, arg3)
128128

129-
def __init__(self):
129+
def __init__(self) -> None:
130130
self.mock = mock.Mock()
131131

132132
obj = Cls()
@@ -156,7 +156,7 @@ def test_cache_kwargs(self):
156156
"""Test that keyword arguments are treated properly"""
157157

158158
class Cls:
159-
def __init__(self):
159+
def __init__(self) -> None:
160160
self.mock = mock.Mock()
161161

162162
@descriptors.cached()
@@ -188,7 +188,7 @@ def fn(self, arg1, kwarg1=2):
188188
self.assertEqual(r, "fish")
189189
obj.mock.assert_not_called()
190190

191-
def test_cache_with_sync_exception(self):
191+
def test_cache_with_sync_exception(self) -> None:
192192
"""If the wrapped function throws synchronously, things should continue to work"""
193193

194194
class Cls:
@@ -209,7 +209,7 @@ def fn(self, arg1):
209209
d = obj.fn(1)
210210
self.failureResultOf(d, SynapseError)
211211

212-
def test_cache_with_async_exception(self):
212+
def test_cache_with_async_exception(self) -> None:
213213
"""The wrapped function returns a failure"""
214214

215215
class Cls:
@@ -349,7 +349,7 @@ def do_lookup():
349349
@defer.inlineCallbacks
350350
def test_cache_default_args(self):
351351
class Cls:
352-
def __init__(self):
352+
def __init__(self) -> None:
353353
self.mock = mock.Mock()
354354

355355
@descriptors.cached()
@@ -386,7 +386,7 @@ def fn(self, arg1, arg2=2, arg3=3):
386386

387387
def test_cache_iterable(self):
388388
class Cls:
389-
def __init__(self):
389+
def __init__(self) -> None:
390390
self.mock = mock.Mock()
391391

392392
@descriptors.cached(iterable=True)
@@ -417,7 +417,7 @@ def fn(self, arg1, arg2):
417417
self.assertEqual(r.result, ["chips"])
418418
obj.mock.assert_not_called()
419419

420-
def test_cache_iterable_with_sync_exception(self):
420+
def test_cache_iterable_with_sync_exception(self) -> None:
421421
"""If the wrapped function throws synchronously, things should continue to work"""
422422

423423
class Cls:
@@ -438,7 +438,7 @@ def fn(self, arg1):
438438
d = obj.fn(1)
439439
self.failureResultOf(d, SynapseError)
440440

441-
def test_invalidate_cascade(self):
441+
def test_invalidate_cascade(self) -> None:
442442
"""Invalidations should cascade up through cache contexts"""
443443

444444
class Cls:
@@ -463,7 +463,7 @@ async def func3(self, key, cache_context):
463463
obj.invalidate()
464464
top_invalidate.assert_called_once()
465465

466-
def test_cancel(self):
466+
def test_cancel(self) -> None:
467467
"""Test that cancelling a lookup does not cancel other lookups"""
468468
complete_lookup: "Deferred[None]" = Deferred()
469469

@@ -488,7 +488,7 @@ async def fn(self, arg1):
488488
self.failureResultOf(d1, CancelledError)
489489
self.assertEqual(d2.result, "123")
490490

491-
def test_cancel_logcontexts(self):
491+
def test_cancel_logcontexts(self) -> None:
492492
"""Test that cancellation does not break logcontexts.
493493
494494
* The `CancelledError` must be raised with the correct logcontext.
@@ -508,7 +508,7 @@ async def fn(self, arg1):
508508

509509
obj = Cls()
510510

511-
async def do_lookup():
511+
async def do_lookup() -> None:
512512
with LoggingContext("c1") as c1:
513513
try:
514514
await obj.fn(123)
@@ -765,7 +765,7 @@ class CachedListDescriptorTestCase(unittest.TestCase):
765765
@defer.inlineCallbacks
766766
def test_cache(self):
767767
class Cls:
768-
def __init__(self):
768+
def __init__(self) -> None:
769769
self.mock = mock.Mock()
770770

771771
@descriptors.cached()
@@ -828,7 +828,7 @@ def test_concurrent_lookups(self):
828828
"""All concurrent lookups should get the same result"""
829829

830830
class Cls:
831-
def __init__(self):
831+
def __init__(self) -> None:
832832
self.mock = mock.Mock()
833833

834834
@descriptors.cached()
@@ -871,7 +871,7 @@ def test_invalidate(self):
871871
"""Make sure that invalidation callbacks are called."""
872872

873873
class Cls:
874-
def __init__(self):
874+
def __init__(self) -> None:
875875
self.mock = mock.Mock()
876876

877877
@descriptors.cached()
@@ -960,7 +960,7 @@ async def list_fn(self, args):
960960

961961
obj = Cls()
962962

963-
async def do_lookup():
963+
async def do_lookup() -> None:
964964
with LoggingContext("c1") as c1:
965965
try:
966966
await obj.list_fn([123])
@@ -983,7 +983,7 @@ async def do_lookup():
983983
)
984984
self.assertEqual(current_context(), SENTINEL_CONTEXT)
985985

986-
def test_num_args_mismatch(self):
986+
def test_num_args_mismatch(self) -> None:
987987
"""
988988
Make sure someone does not accidentally use @cachedList on a method with
989989
a mismatch in the number args to the underlying single cache method.

0 commit comments

Comments
 (0)