Skip to content

Commit 4c1286c

Browse files
committed
fix: modify Union[bytes, int] to bytes for read
1 parent 4ccf81a commit 4c1286c

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

Diff for: pymysqlreplication/packet.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def __init__(self,
151151
if self.event._processed == False:
152152
self.event = None
153153

154-
def read(self, size: int) -> Union[int, bytes]:
154+
def read(self, size: int) -> bytes:
155155
size = int(size)
156156
self.read_bytes += size
157157
if len(self.__data_buffer) > 0:
@@ -163,7 +163,7 @@ def read(self, size: int) -> Union[int, bytes]:
163163
return data + self.packet.read(size - len(data))
164164
return self.packet.read(size)
165165

166-
def unread(self, data: Union[int, bytes]) -> None:
166+
def unread(self, data: bytes) -> None:
167167
"""
168168
Push again data in data buffer.
169169
Use to extract a bit from a value and ensure that the rest of the code reads data normally
@@ -257,15 +257,15 @@ def read_uint_by_size(self, size: int) -> int:
257257
elif size == 8:
258258
return self.read_uint64()
259259

260-
def read_length_coded_pascal_string(self, size: int) -> Union[int, bytes]:
260+
def read_length_coded_pascal_string(self, size: int) -> bytes:
261261
"""
262262
Read a string with length coded using pascal style.
263263
The string start by the size of the string
264264
"""
265265
length = self.read_uint_by_size(size)
266266
return self.read(length)
267267

268-
def read_variable_length_string(self) -> Union[int, bytes]:
268+
def read_variable_length_string(self) -> bytes:
269269
"""
270270
Read a variable length string where the first 1-5 bytes stores the length of the string.
271271
For each byte, the first bit being high indicates another byte must be read.
@@ -367,8 +367,8 @@ def read_binary_json(self, size: int) -> Optional[str]:
367367

368368
def read_binary_json_type(self, t: int, length: int) \
369369
-> Optional[Union[
370-
Dict[Union[int, bytes], Union[bool, str, None]],
371-
List[int], bool, int]]:
370+
Dict[bytes, Union[bool, str, None]],
371+
List[int], bool, int, bytes]]:
372372
large = (t in (JSONB_TYPE_LARGE_OBJECT, JSONB_TYPE_LARGE_ARRAY))
373373
if t in (JSONB_TYPE_SMALL_OBJECT, JSONB_TYPE_LARGE_OBJECT):
374374
return self.read_binary_json_object(length - 1, large)
@@ -422,7 +422,7 @@ def read_binary_json_type_inlined(self, t: bytes, large: bool) -> Optional[Union
422422
raise ValueError('Json type %d is not handled' % t)
423423

424424
def read_binary_json_object(self, length: int, large: bool) \
425-
-> Dict[Union[int, bytes], Union[bool, str, None]]:
425+
-> Dict[bytes, Union[bool, str, None]]:
426426
if large:
427427
elements = self.read_uint32()
428428
size = self.read_uint32()

0 commit comments

Comments
 (0)