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