@@ -47,7 +47,7 @@ class DescriptorTestCase(unittest.TestCase):
47
47
@defer .inlineCallbacks
48
48
def test_cache (self ):
49
49
class Cls :
50
- def __init__ (self ):
50
+ def __init__ (self ) -> None :
51
51
self .mock = mock .Mock ()
52
52
53
53
@descriptors .cached ()
@@ -81,7 +81,7 @@ def test_cache_num_args(self):
81
81
"""Only the first num_args arguments should matter to the cache"""
82
82
83
83
class Cls :
84
- def __init__ (self ):
84
+ def __init__ (self ) -> None :
85
85
self .mock = mock .Mock ()
86
86
87
87
@descriptors .cached (num_args = 1 )
@@ -126,7 +126,7 @@ class Cls:
126
126
def fn (self , arg1 , arg2 , arg3 ):
127
127
return self .mock (arg1 , arg2 , arg3 )
128
128
129
- def __init__ (self ):
129
+ def __init__ (self ) -> None :
130
130
self .mock = mock .Mock ()
131
131
132
132
obj = Cls ()
@@ -156,7 +156,7 @@ def test_cache_kwargs(self):
156
156
"""Test that keyword arguments are treated properly"""
157
157
158
158
class Cls :
159
- def __init__ (self ):
159
+ def __init__ (self ) -> None :
160
160
self .mock = mock .Mock ()
161
161
162
162
@descriptors .cached ()
@@ -188,7 +188,7 @@ def fn(self, arg1, kwarg1=2):
188
188
self .assertEqual (r , "fish" )
189
189
obj .mock .assert_not_called ()
190
190
191
- def test_cache_with_sync_exception (self ):
191
+ def test_cache_with_sync_exception (self ) -> None :
192
192
"""If the wrapped function throws synchronously, things should continue to work"""
193
193
194
194
class Cls :
@@ -209,7 +209,7 @@ def fn(self, arg1):
209
209
d = obj .fn (1 )
210
210
self .failureResultOf (d , SynapseError )
211
211
212
- def test_cache_with_async_exception (self ):
212
+ def test_cache_with_async_exception (self ) -> None :
213
213
"""The wrapped function returns a failure"""
214
214
215
215
class Cls :
@@ -349,7 +349,7 @@ def do_lookup():
349
349
@defer .inlineCallbacks
350
350
def test_cache_default_args (self ):
351
351
class Cls :
352
- def __init__ (self ):
352
+ def __init__ (self ) -> None :
353
353
self .mock = mock .Mock ()
354
354
355
355
@descriptors .cached ()
@@ -386,7 +386,7 @@ def fn(self, arg1, arg2=2, arg3=3):
386
386
387
387
def test_cache_iterable (self ):
388
388
class Cls :
389
- def __init__ (self ):
389
+ def __init__ (self ) -> None :
390
390
self .mock = mock .Mock ()
391
391
392
392
@descriptors .cached (iterable = True )
@@ -417,7 +417,7 @@ def fn(self, arg1, arg2):
417
417
self .assertEqual (r .result , ["chips" ])
418
418
obj .mock .assert_not_called ()
419
419
420
- def test_cache_iterable_with_sync_exception (self ):
420
+ def test_cache_iterable_with_sync_exception (self ) -> None :
421
421
"""If the wrapped function throws synchronously, things should continue to work"""
422
422
423
423
class Cls :
@@ -438,7 +438,7 @@ def fn(self, arg1):
438
438
d = obj .fn (1 )
439
439
self .failureResultOf (d , SynapseError )
440
440
441
- def test_invalidate_cascade (self ):
441
+ def test_invalidate_cascade (self ) -> None :
442
442
"""Invalidations should cascade up through cache contexts"""
443
443
444
444
class Cls :
@@ -463,7 +463,7 @@ async def func3(self, key, cache_context):
463
463
obj .invalidate ()
464
464
top_invalidate .assert_called_once ()
465
465
466
- def test_cancel (self ):
466
+ def test_cancel (self ) -> None :
467
467
"""Test that cancelling a lookup does not cancel other lookups"""
468
468
complete_lookup : "Deferred[None]" = Deferred ()
469
469
@@ -488,7 +488,7 @@ async def fn(self, arg1):
488
488
self .failureResultOf (d1 , CancelledError )
489
489
self .assertEqual (d2 .result , "123" )
490
490
491
- def test_cancel_logcontexts (self ):
491
+ def test_cancel_logcontexts (self ) -> None :
492
492
"""Test that cancellation does not break logcontexts.
493
493
494
494
* The `CancelledError` must be raised with the correct logcontext.
@@ -508,7 +508,7 @@ async def fn(self, arg1):
508
508
509
509
obj = Cls ()
510
510
511
- async def do_lookup ():
511
+ async def do_lookup () -> None :
512
512
with LoggingContext ("c1" ) as c1 :
513
513
try :
514
514
await obj .fn (123 )
@@ -765,7 +765,7 @@ class CachedListDescriptorTestCase(unittest.TestCase):
765
765
@defer .inlineCallbacks
766
766
def test_cache (self ):
767
767
class Cls :
768
- def __init__ (self ):
768
+ def __init__ (self ) -> None :
769
769
self .mock = mock .Mock ()
770
770
771
771
@descriptors .cached ()
@@ -828,7 +828,7 @@ def test_concurrent_lookups(self):
828
828
"""All concurrent lookups should get the same result"""
829
829
830
830
class Cls :
831
- def __init__ (self ):
831
+ def __init__ (self ) -> None :
832
832
self .mock = mock .Mock ()
833
833
834
834
@descriptors .cached ()
@@ -871,7 +871,7 @@ def test_invalidate(self):
871
871
"""Make sure that invalidation callbacks are called."""
872
872
873
873
class Cls :
874
- def __init__ (self ):
874
+ def __init__ (self ) -> None :
875
875
self .mock = mock .Mock ()
876
876
877
877
@descriptors .cached ()
@@ -960,7 +960,7 @@ async def list_fn(self, args):
960
960
961
961
obj = Cls ()
962
962
963
- async def do_lookup ():
963
+ async def do_lookup () -> None :
964
964
with LoggingContext ("c1" ) as c1 :
965
965
try :
966
966
await obj .list_fn ([123 ])
@@ -983,7 +983,7 @@ async def do_lookup():
983
983
)
984
984
self .assertEqual (current_context (), SENTINEL_CONTEXT )
985
985
986
- def test_num_args_mismatch (self ):
986
+ def test_num_args_mismatch (self ) -> None :
987
987
"""
988
988
Make sure someone does not accidentally use @cachedList on a method with
989
989
a mismatch in the number args to the underlying single cache method.
0 commit comments