@@ -151,7 +151,7 @@ def __init__(self,
151
151
if self .event ._processed == False :
152
152
self .event = None
153
153
154
- def read (self , size : int ) -> Union [ int , bytes ] :
154
+ def read (self , size : int ) -> bytes :
155
155
size = int (size )
156
156
self .read_bytes += size
157
157
if len (self .__data_buffer ) > 0 :
@@ -163,7 +163,7 @@ def read(self, size: int) -> Union[int, bytes]:
163
163
return data + self .packet .read (size - len (data ))
164
164
return self .packet .read (size )
165
165
166
- def unread (self , data : Union [ int , bytes ] ) -> None :
166
+ def unread (self , data : bytes ) -> None :
167
167
"""
168
168
Push again data in data buffer.
169
169
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:
257
257
elif size == 8 :
258
258
return self .read_uint64 ()
259
259
260
- def read_length_coded_pascal_string (self , size : int ) -> Union [ int , bytes ] :
260
+ def read_length_coded_pascal_string (self , size : int ) -> bytes :
261
261
"""
262
262
Read a string with length coded using pascal style.
263
263
The string start by the size of the string
264
264
"""
265
265
length = self .read_uint_by_size (size )
266
266
return self .read (length )
267
267
268
- def read_variable_length_string (self ) -> Union [ int , bytes ] :
268
+ def read_variable_length_string (self ) -> bytes :
269
269
"""
270
270
Read a variable length string where the first 1-5 bytes stores the length of the string.
271
271
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]:
367
367
368
368
def read_binary_json_type (self , t : int , length : int ) \
369
369
-> 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 ]]:
372
372
large = (t in (JSONB_TYPE_LARGE_OBJECT , JSONB_TYPE_LARGE_ARRAY ))
373
373
if t in (JSONB_TYPE_SMALL_OBJECT , JSONB_TYPE_LARGE_OBJECT ):
374
374
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
422
422
raise ValueError ('Json type %d is not handled' % t )
423
423
424
424
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 ]]:
426
426
if large :
427
427
elements = self .read_uint32 ()
428
428
size = self .read_uint32 ()
0 commit comments