Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/obspec/_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class GetOptions(TypedDict, total=False):
<https://datatracker.ietf.org/doc/html/rfc9110#section-13.1.4>
"""

range: tuple[int, int] | list[int] | OffsetRange | SuffixRange
range: tuple[int, int] | Sequence[int] | OffsetRange | SuffixRange
"""
Request transfer of only the specified range of bytes.

Expand Down Expand Up @@ -371,7 +371,7 @@ def get_ranges(
starts: Sequence[int],
ends: Sequence[int] | None = None,
lengths: Sequence[int] | None = None,
) -> list[Buffer]:
) -> Sequence[Buffer]:
"""Return the bytes stored at the specified location in the given byte ranges.

To improve performance this will:
Expand Down Expand Up @@ -407,7 +407,7 @@ async def get_ranges_async(
starts: Sequence[int],
ends: Sequence[int] | None = None,
lengths: Sequence[int] | None = None,
) -> list[Buffer]:
) -> Sequence[Buffer]:
"""Call `get_ranges` asynchronously.

Refer to the documentation for [GetRanges][obspec.GetRanges].
Expand Down
31 changes: 20 additions & 11 deletions src/obspec/_list.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
from __future__ import annotations

from typing import Generic, Literal, Protocol, Self, TypedDict, TypeVar, overload
from collections.abc import Sequence
from typing import (
Generic,
Literal,
Protocol,
Self,
TypedDict,
TypeVar,
overload,
)

from ._meta import ObjectMeta
from .arrow import ArrowArrayExportable, ArrowStreamExportable

ListChunkType_co = TypeVar(
"ListChunkType_co",
list[ObjectMeta],
Sequence[ObjectMeta],
ArrowArrayExportable,
ArrowStreamExportable,
covariant=True,
Expand All @@ -28,7 +37,7 @@ class ListResult(TypedDict, Generic[ListChunkType_co]):
object storage's limitations.
"""

common_prefixes: list[str]
common_prefixes: Sequence[str]
"""Prefixes that are common (like directories)"""

objects: ListChunkType_co
Expand Down Expand Up @@ -93,15 +102,15 @@ def list(
offset: str | None = None,
chunk_size: int = 50,
return_arrow: Literal[False] = False,
) -> ListIterator[list[ObjectMeta]]: ...
) -> ListIterator[Sequence[ObjectMeta]]: ...
def list(
self,
prefix: str | None = None,
*,
offset: str | None = None,
chunk_size: int = 50,
return_arrow: bool = False,
) -> ListIterator[ArrowArrayExportable] | ListIterator[list[ObjectMeta]]:
) -> ListIterator[ArrowArrayExportable] | ListIterator[Sequence[ObjectMeta]]:
"""List all the objects with the given prefix.

Prefixes are evaluated on a path segment basis, i.e. `foo/bar/` is a prefix of
Expand Down Expand Up @@ -192,15 +201,15 @@ def list_async(
offset: str | None = None,
chunk_size: int = 50,
return_arrow: Literal[False] = False,
) -> ListStream[list[ObjectMeta]]: ...
) -> ListStream[Sequence[ObjectMeta]]: ...
def list_async(
self,
prefix: str | None = None,
*,
offset: str | None = None,
chunk_size: int = 50,
return_arrow: bool = False,
) -> ListStream[ArrowArrayExportable] | ListStream[list[ObjectMeta]]:
) -> ListStream[ArrowArrayExportable] | ListStream[Sequence[ObjectMeta]]:
"""List all the objects with the given prefix.

Note that this method itself is **not async**. It's a synchronous method but
Expand Down Expand Up @@ -260,13 +269,13 @@ def list_with_delimiter(
prefix: str | None = None,
*,
return_arrow: Literal[False] = False,
) -> ListResult[list[ObjectMeta]]: ...
) -> ListResult[Sequence[ObjectMeta]]: ...
def list_with_delimiter(
self,
prefix: str | None = None,
*,
return_arrow: bool = False,
) -> ListResult[ArrowStreamExportable] | ListResult[list[ObjectMeta]]:
) -> ListResult[ArrowStreamExportable] | ListResult[Sequence[ObjectMeta]]:
"""List objects with the given prefix and an implementation specific
delimiter.

Expand Down Expand Up @@ -313,13 +322,13 @@ async def list_with_delimiter_async(
prefix: str | None = None,
*,
return_arrow: Literal[False] = False,
) -> ListResult[list[ObjectMeta]]: ...
) -> ListResult[Sequence[ObjectMeta]]: ...
async def list_with_delimiter_async(
self,
prefix: str | None = None,
*,
return_arrow: bool = False,
) -> ListResult[ArrowStreamExportable] | ListResult[list[ObjectMeta]]:
) -> ListResult[ArrowStreamExportable] | ListResult[Sequence[ObjectMeta]]:
"""Call `list_with_delimiter` asynchronously.

Refer to the documentation for
Expand Down
Loading