mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-23 23:02:25 +00:00
Work on 3.8.
This commit is contained in:
parent
4befcacc60
commit
464b476190
@ -5,7 +5,7 @@ HTTP client that talks to the HTTP storage server.
|
||||
from __future__ import annotations
|
||||
|
||||
from eliot import start_action, register_exception_extractor
|
||||
from typing import Union, Optional, Sequence, Mapping, BinaryIO, cast, TypedDict
|
||||
from typing import Union, Optional, Sequence, Mapping, BinaryIO, cast, TypedDict, Set
|
||||
from base64 import b64encode
|
||||
from io import BytesIO
|
||||
from os import SEEK_END
|
||||
@ -487,14 +487,14 @@ class StorageClientGeneral(object):
|
||||
url = self._client.relative_url("/storage/v1/version")
|
||||
response = await self._client.request("GET", url)
|
||||
decoded_response = cast(
|
||||
dict[bytes, object],
|
||||
Mapping[bytes, object],
|
||||
await self._client.decode_cbor(response, _SCHEMAS["get_version"]),
|
||||
)
|
||||
# Add some features we know are true because the HTTP API
|
||||
# specification requires them and because other parts of the storage
|
||||
# client implementation assumes they will be present.
|
||||
cast(
|
||||
dict[bytes, object],
|
||||
Mapping[bytes, object],
|
||||
decoded_response[b"http://allmydata.org/tahoe/protocols/storage/v1"],
|
||||
).update(
|
||||
{
|
||||
@ -692,7 +692,7 @@ class StorageClientImmutables(object):
|
||||
message_to_serialize=message,
|
||||
)
|
||||
decoded_response = cast(
|
||||
dict[str, set[int]],
|
||||
Mapping[str, Set[int]],
|
||||
await self._client.decode_cbor(response, _SCHEMAS["allocate_buckets"]),
|
||||
)
|
||||
return ImmutableCreateResult(
|
||||
@ -774,7 +774,7 @@ class StorageClientImmutables(object):
|
||||
response.code,
|
||||
)
|
||||
body = cast(
|
||||
dict[str, list[dict[str, int]]],
|
||||
Mapping[str, Sequence[Mapping[str, int]]],
|
||||
await self._client.decode_cbor(
|
||||
response, _SCHEMAS["immutable_write_share_chunk"]
|
||||
),
|
||||
@ -795,7 +795,7 @@ class StorageClientImmutables(object):
|
||||
)
|
||||
|
||||
@async_to_deferred
|
||||
async def list_shares(self, storage_index: bytes) -> set[int]:
|
||||
async def list_shares(self, storage_index: bytes) -> Set[int]:
|
||||
"""
|
||||
Return the set of shares for a given storage index.
|
||||
"""
|
||||
@ -808,7 +808,7 @@ class StorageClientImmutables(object):
|
||||
)
|
||||
if response.code == http.OK:
|
||||
body = cast(
|
||||
set[int],
|
||||
Set[int],
|
||||
await self._client.decode_cbor(response, _SCHEMAS["list_shares"]),
|
||||
)
|
||||
return set(body)
|
||||
@ -881,9 +881,10 @@ class ReadTestWriteResult:
|
||||
reads: Mapping[int, Sequence[bytes]]
|
||||
|
||||
|
||||
# Result type for mutable read/test/write HTTP response.
|
||||
# Result type for mutable read/test/write HTTP response. Can't just use
|
||||
# dict[int,list[bytes]] because on Python 3.8 that will error out.
|
||||
MUTABLE_RTW = TypedDict(
|
||||
"MUTABLE_RTW", {"success": bool, "data": dict[int, list[bytes]]}
|
||||
"MUTABLE_RTW", {"success": bool, "data": Mapping[int, Sequence[bytes]]}
|
||||
)
|
||||
|
||||
|
||||
@ -958,7 +959,7 @@ class StorageClientMutables:
|
||||
)
|
||||
|
||||
@async_to_deferred
|
||||
async def list_shares(self, storage_index: bytes) -> set[int]:
|
||||
async def list_shares(self, storage_index: bytes) -> Set[int]:
|
||||
"""
|
||||
List the share numbers for a given storage index.
|
||||
"""
|
||||
@ -968,7 +969,7 @@ class StorageClientMutables:
|
||||
response = await self._client.request("GET", url)
|
||||
if response.code == http.OK:
|
||||
return cast(
|
||||
set[int],
|
||||
Set[int],
|
||||
await self._client.decode_cbor(
|
||||
response, _SCHEMAS["mutable_list_shares"]
|
||||
),
|
||||
|
Loading…
Reference in New Issue
Block a user