Fix some type hints (EndianBinaryReader, EndianBinaryWriter)#293
Fix some type hints (EndianBinaryReader, EndianBinaryWriter)#293K0lb3 merged 3 commits intoK0lb3:masterfrom
Conversation
|
What is the point of |
Here is a minimal example shows why class EndianBinaryReader:
endian: str
...
def __new__(cls, ...):
...
def __init__(self, ...):
...
@property
def bytes(self):
# implemented by Streamable and Memoryview versions
return b""
...
def read_bytes(self, num) -> builtins.bytes:
return self.read(num)
...In the code above, So, if the type hint still uses To avoid this problem, it's recommended to use |
|
I caught some other type hints issues in By the way, I want to ask a small question: class EndianBinaryReader_Memoryview(EndianBinaryReader):
__slots__ = ("view", "_endian", "BaseOffset", "Position", "Length")
view: memoryview
def __init__(self, view, endian: str = ">", offset: int = 0):
self._endian = ""
super().__init__(view, endian=endian, offset=offset)
self.view = memoryview(view)
self.Length = len(view)Why you use |
It's certainly not a great solution and could be done better. |

Summary
This PR mainly fixes some type hints in
EndianBinaryReaderandEndianBinaryWriter.By the way, some minor code issues are fixed, including:
passstatement) are removed.For more details, please refer to the commits.