diff --git a/structer/errors.py b/structer/errors.py index 361389b..7525a0e 100644 --- a/structer/errors.py +++ b/structer/errors.py @@ -14,8 +14,5 @@ def str_value_oversized_error(field_type): message = ( '`{}` value size must be {} bytes at most ' '(accents usually occupy more than one byte)' - ).format( - type(field_type).__name__, - field_type._size - ) - return ValueError(message) \ No newline at end of file + ).format(type(field_type).__name__, field_type._size) + return ValueError(message) diff --git a/structer/struct.py b/structer/struct.py index 0ad1b8f..2475d50 100644 --- a/structer/struct.py +++ b/structer/struct.py @@ -1,5 +1,5 @@ from types import MappingProxyType -from typing import ClassVar, Sequence, NoReturn +from typing import ClassVar, NoReturn, Sequence from . import errors from .field import Field @@ -68,7 +68,10 @@ def __init__(self, **kwargs): else: field_value = field.type.decode(b'\0') - self.__struct_offsets__[field.name] = start_range, start_range + field.type.size + self.__struct_offsets__[field.name] = ( + start_range, + start_range + field.type.size, + ) self.__setattr__(field.name, field_value) setattr( self, '__struct_size__', self.__struct_size__ + field.type.size @@ -76,8 +79,11 @@ def __init__(self, **kwargs): start_range += field.type.size - setattr(self, '__struct_offsets__', MappingProxyType(self.__struct_offsets__)) - + setattr( + self, + '__struct_offsets__', + MappingProxyType(self.__struct_offsets__), + ) def __len__(self): return self.__struct_size__