mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-12-10 05:49:55 -05:00
Type tests.utils (#13028)
* Cast to postgres types when handling postgres db * Remove unused method * Easy annotations * Annotate create_room * Use `ParamSpec` to annotate looping_call * Annotate `default_config` * Track `now` as a float `time_ms` returns an int like the proper Synapse `Clock` * Introduce a `Timer` dataclass * Introduce a Looper type * Suppress checking of a mock * tests.utils is typed * Changelog * Whoops, import ParamSpec from typing_extensions * ditch the psycopg2 casts
This commit is contained in:
parent
68695d8007
commit
6ba732fefe
5 changed files with 101 additions and 45 deletions
|
|
@ -20,6 +20,7 @@ from typing import Any, Callable, Dict, Generator, Optional
|
|||
import attr
|
||||
from frozendict import frozendict
|
||||
from matrix_common.versionstring import get_distribution_version_string
|
||||
from typing_extensions import ParamSpec
|
||||
|
||||
from twisted.internet import defer, task
|
||||
from twisted.internet.defer import Deferred
|
||||
|
|
@ -82,6 +83,9 @@ def unwrapFirstError(failure: Failure) -> Failure:
|
|||
return failure.value.subFailure # type: ignore[union-attr] # Issue in Twisted's annotations
|
||||
|
||||
|
||||
P = ParamSpec("P")
|
||||
|
||||
|
||||
@attr.s(slots=True)
|
||||
class Clock:
|
||||
"""
|
||||
|
|
@ -110,7 +114,7 @@ class Clock:
|
|||
return int(self.time() * 1000)
|
||||
|
||||
def looping_call(
|
||||
self, f: Callable, msec: float, *args: Any, **kwargs: Any
|
||||
self, f: Callable[P, object], msec: float, *args: P.args, **kwargs: P.kwargs
|
||||
) -> LoopingCall:
|
||||
"""Call a function repeatedly.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue