Skip to content

Commit 20f7987

Browse files
committed
Add bound for TypeVar in common.py.
1 parent 2f74e3f commit 20f7987

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

apyds/common.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,28 @@
99
import typing
1010
from .buffer_size import buffer_size
1111

12-
T = typing.TypeVar("T")
12+
13+
class DsProto(typing.Protocol):
14+
"""Protocol for deductive system base types."""
15+
16+
@classmethod
17+
def from_string(cls, string: str, capacity: int) -> typing.Self: ...
18+
19+
@classmethod
20+
def from_binary(cls, binary: memoryview) -> typing.Self: ...
21+
22+
@classmethod
23+
def to_string(cls, value: typing.Self, capacity: int) -> str: ...
24+
25+
@classmethod
26+
def to_binary(cls, value: typing.Self) -> bytes: ...
27+
28+
def data_size(self) -> int: ...
29+
30+
def clone(self) -> typing.Self: ...
31+
32+
33+
T = typing.TypeVar("T", bound=DsProto)
1334

1435

1536
class Common(typing.Generic[T]):

0 commit comments

Comments
 (0)