Skip to content

Commit

Permalink
Replace xxxxableBuffer with SupportsXxxx
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaLeivers committed Oct 16, 2023
1 parent 5687964 commit 2d682a9
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/betterproto/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@

if TYPE_CHECKING:
from _typeshed import (
ReadableBuffer,
WriteableBuffer,
SupportsRead,
SupportsWrite,
)


Expand Down Expand Up @@ -328,7 +328,7 @@ def _pack_fmt(proto_type: str) -> str:
}[proto_type]


def dump_varint(value: int, stream: "WriteableBuffer") -> None:
def dump_varint(value: int, stream: "SupportsWrite[bytes]") -> None:
"""Encodes a single varint and dumps it into the provided stream."""
if value < -(1 << 63):
raise ValueError(
Expand Down Expand Up @@ -537,7 +537,7 @@ def _dump_float(value: float) -> Union[float, str]:
return value


def load_varint(stream: "ReadableBuffer") -> Tuple[int, bytes]:
def load_varint(stream: "SupportsRead[bytes]") -> Tuple[int, bytes]:
"""
Load a single varint value from a stream. Returns the value and the raw bytes read.
"""
Expand Down Expand Up @@ -575,7 +575,7 @@ class ParsedField:
raw: bytes


def load_fields(stream: "ReadableBuffer") -> Generator[ParsedField, None, None]:
def load_fields(stream: "SupportsRead[bytes]") -> Generator[ParsedField, None, None]:
while True:
try:
num_wire, raw = load_varint(stream)
Expand Down Expand Up @@ -887,7 +887,7 @@ def _betterproto(self) -> ProtoClassMetadata:
self.__class__._betterproto_meta = meta # type: ignore
return meta

def dump(self, stream: "WriteableBuffer", delimit: bool = False) -> None:
def dump(self, stream: "SupportsWrite[bytes]", delimit: bool = False) -> None:
"""
Dumps the binary encoded Protobuf message to the stream.
Expand Down Expand Up @@ -1219,7 +1219,7 @@ def _include_default_value_for_oneof(

def load(
self: T,
stream: "ReadableBuffer",
stream: "SupportsRead[bytes]",
size: Optional[int] = None,
) -> T:
"""
Expand Down

0 comments on commit 2d682a9

Please sign in to comment.