2828from typing import cast , Any , BinaryIO , Optional , Type , Union
2929from .base import STRUCTS
3030import hashlib
31- from .c_parser import ( parse_struct , parse_def , Tokens )
31+ from .c_parser import parse_struct , parse_def , Tokens
3232
33- __all__ = [
34- 'CStructMeta' ,
35- 'AbstractCStruct'
36- ]
33+ __all__ = ['CStructMeta' , 'AbstractCStruct' ]
3734
38- class CStructMeta (ABCMeta ):
3935
36+ class CStructMeta (ABCMeta ):
4037 def __new__ (cls , name : str , bases , dct ):
4138 __struct__ = dct .get ("__struct__" , None )
4239 dct ['__cls__' ] = bases [0 ]
@@ -60,16 +57,16 @@ def __len__(cls) -> int:
6057
6158 @property
6259 def size (cls ) -> int :
63- """ Structure size (in bytes) """
60+ """Structure size (in bytes)"""
6461 return cls .__size__
6562
63+
6664# Workaround for Python 2.x/3.x metaclass, thanks to
6765# http://mikewatkins.ca/2008/11/29/python-2-and-3-metaclasses/#using-the-metaclass-in-python-2-x-and-3-x
68- _CStructParent = CStructMeta ('_CStructParent' , (object , ), {})
66+ _CStructParent = CStructMeta ('_CStructParent' , (object ,), {})
6967
7068
7169class AbstractCStruct (_CStructParent ):
72-
7370 def __init__ (self , buffer = None , ** kargs ) -> None :
7471 if buffer is not None :
7572 self .unpack (buffer )
@@ -135,16 +132,16 @@ def clear(self) -> None:
135132 self .unpack (None )
136133
137134 def __len__ (self ) -> int :
138- """ Structure size (in bytes) """
135+ """Structure size (in bytes)"""
139136 return cast (int , self .__size__ )
140137
141138 @property
142139 def size (self ) -> int :
143- """ Structure size (in bytes) """
140+ """Structure size (in bytes)"""
144141 return self .__size__
145142
146143 def __eq__ (self , other : Any ) -> bool :
147- return ( isinstance (other , self .__class__ ) and self .__dict__ == other .__dict__ )
144+ return isinstance (other , self .__class__ ) and self .__dict__ == other .__dict__
148145
149146 def __ne__ (self , other : Any ) -> bool :
150147 return not self .__eq__ (other )
0 commit comments