mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-31 08:25:35 +00:00
Pacify mypy
This commit is contained in:
parent
bf5213cb01
commit
8d99ddc542
@ -8,7 +8,7 @@ import json
|
|||||||
import os
|
import os
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from os.path import join
|
from os.path import join
|
||||||
from typing import Awaitable, Callable, Optional, Sequence, TypeVar, Union
|
from typing import Callable, Optional, Sequence, TypeVar, Union, Coroutine, Any, Tuple, cast, Generator
|
||||||
|
|
||||||
from twisted.internet import defer
|
from twisted.internet import defer
|
||||||
from twisted.trial import unittest
|
from twisted.trial import unittest
|
||||||
@ -60,7 +60,7 @@ def make_simple_peer(
|
|||||||
server: MemoryWormholeServer,
|
server: MemoryWormholeServer,
|
||||||
helper: TestingHelper,
|
helper: TestingHelper,
|
||||||
messages: Sequence[JSONable],
|
messages: Sequence[JSONable],
|
||||||
) -> Callable[[], Awaitable[IWormhole]]:
|
) -> Callable[[], Coroutine[defer.Deferred[IWormhole], Any, IWormhole]]:
|
||||||
"""
|
"""
|
||||||
Make a wormhole peer that just sends the given messages.
|
Make a wormhole peer that just sends the given messages.
|
||||||
|
|
||||||
@ -102,18 +102,24 @@ A = TypeVar("A")
|
|||||||
B = TypeVar("B")
|
B = TypeVar("B")
|
||||||
|
|
||||||
def concurrently(
|
def concurrently(
|
||||||
client: Callable[[], Awaitable[A]],
|
client: Callable[[], Union[
|
||||||
server: Callable[[], Awaitable[B]],
|
Coroutine[defer.Deferred[A], Any, A],
|
||||||
) -> defer.Deferred[tuple[A, B]]:
|
Generator[defer.Deferred[A], Any, A],
|
||||||
|
]],
|
||||||
|
server: Callable[[], Union[
|
||||||
|
Coroutine[defer.Deferred[B], Any, B],
|
||||||
|
Generator[defer.Deferred[B], Any, B],
|
||||||
|
]],
|
||||||
|
) -> defer.Deferred[Tuple[A, B]]:
|
||||||
"""
|
"""
|
||||||
Run two asynchronous functions concurrently and asynchronously return a
|
Run two asynchronous functions concurrently and asynchronously return a
|
||||||
tuple of both their results.
|
tuple of both their results.
|
||||||
"""
|
"""
|
||||||
return defer.gatherResults([
|
result = defer.gatherResults([
|
||||||
defer.Deferred.fromCoroutine(client()),
|
defer.Deferred.fromCoroutine(client()),
|
||||||
defer.Deferred.fromCoroutine(server()),
|
defer.Deferred.fromCoroutine(server()),
|
||||||
])
|
]).addCallback(tuple) # type: ignore
|
||||||
|
return cast(defer.Deferred[Tuple[A, B]], result)
|
||||||
|
|
||||||
class Join(GridTestMixin, CLITestMixin, unittest.TestCase):
|
class Join(GridTestMixin, CLITestMixin, unittest.TestCase):
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user