Skip to content

Implement SizedSliceable protocol in src/graphql_relay/connection/arrayconnection.py #31

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 3, 2020
Merged
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
16 changes: 13 additions & 3 deletions src/graphql_relay/connection/arrayconnection.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import binascii
import warnings
from typing import Any, Optional, Sequence
from typing import Any, Iterator, Optional, Sequence
try:
from typing import Protocol
except ImportError:
from typing_extensions import Protocol # type: ignore

from ..utils.base64 import base64, unbase64
from .connectiontypes import (
Expand All @@ -25,8 +29,14 @@
]


class SizedSliceable(Protocol):
def __getitem__(self, index: slice) -> Any: ...
def __iter__(self) -> Iterator: ...
def __len__(self) -> int: ...


def connection_from_array(
data: Sequence,
data: SizedSliceable,
args: ConnectionArguments = None,
connection_type: ConnectionConstructor = Connection,
edge_type: EdgeConstructor = Edge,
Expand Down Expand Up @@ -83,7 +93,7 @@ def connection_from_list(


def connection_from_array_slice(
array_slice: Sequence,
array_slice: SizedSliceable,
args: ConnectionArguments = None,
slice_start: int = 0,
array_length: int = None,
Expand Down