-
-
Notifications
You must be signed in to change notification settings - Fork 162
Fix some type hints (EndianBinaryReader, EndianBinaryWriter) #293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
K0lb3
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot 👍
|
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.