Fix linting errors
This commit is contained in:
parent
23c743570e
commit
494984f7d3
|
@ -26,7 +26,7 @@ def serialize_basic(value: SSZValue):
|
||||||
def deserialize_basic(value, typ: BasicType):
|
def deserialize_basic(value, typ: BasicType):
|
||||||
if issubclass(typ, uint):
|
if issubclass(typ, uint):
|
||||||
return typ(int.from_bytes(value, 'little'))
|
return typ(int.from_bytes(value, 'little'))
|
||||||
elif issubclass(typ, Bool):
|
elif issubclass(typ, boolean):
|
||||||
assert value in (b'\x00', b'\x01')
|
assert value in (b'\x00', b'\x01')
|
||||||
return typ(value == b'\x01')
|
return typ(value == b'\x01')
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -280,12 +280,15 @@ class ElementsType(ParamsMeta):
|
||||||
elem_type: SSZType
|
elem_type: SSZType
|
||||||
length: int
|
length: int
|
||||||
|
|
||||||
|
|
||||||
class BitElementsType(ElementsType):
|
class BitElementsType(ElementsType):
|
||||||
elem_type = boolean
|
elem_type = boolean
|
||||||
|
|
||||||
|
|
||||||
class Elements(ParamsBase, metaclass=ElementsType):
|
class Elements(ParamsBase, metaclass=ElementsType):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class BaseList(list, Elements):
|
class BaseList(list, Elements):
|
||||||
|
|
||||||
def __init__(self, *args):
|
def __init__(self, *args):
|
||||||
|
@ -342,12 +345,15 @@ class BaseList(list, Elements):
|
||||||
# be explict about getting the last item, for the non-python readers, and negative-index safety
|
# be explict about getting the last item, for the non-python readers, and negative-index safety
|
||||||
return self[len(self) - 1]
|
return self[len(self) - 1]
|
||||||
|
|
||||||
|
|
||||||
class BaseBitfield(BaseList, metaclass=BitElementsType):
|
class BaseBitfield(BaseList, metaclass=BitElementsType):
|
||||||
elem_type = bool
|
elem_type = bool
|
||||||
|
|
||||||
|
|
||||||
class Bitlist(BaseBitfield):
|
class Bitlist(BaseBitfield):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class Bitvector(BaseBitfield):
|
class Bitvector(BaseBitfield):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
@ -81,8 +81,10 @@ test_data = [
|
||||||
("boolean T", boolean(True), "01", chunk("01")),
|
("boolean T", boolean(True), "01", chunk("01")),
|
||||||
("bitvector TFTFFFTTFT", Bitvector[10](1, 0, 1, 0, 0, 0, 1, 1, 0, 1), "c502", chunk("c502")),
|
("bitvector TFTFFFTTFT", Bitvector[10](1, 0, 1, 0, 0, 0, 1, 1, 0, 1), "c502", chunk("c502")),
|
||||||
("bitlist TFTFFFTTFT", Bitlist[16](1, 0, 1, 0, 0, 0, 1, 1, 0, 1), "c506", h(chunk("c502"), chunk("0A"))),
|
("bitlist TFTFFFTTFT", Bitlist[16](1, 0, 1, 0, 0, 0, 1, 1, 0, 1), "c506", h(chunk("c502"), chunk("0A"))),
|
||||||
("bitvector TFTFFFTTFTFFFFTT", Bitvector[16](1,0,1,0,0,0,1,1,0,1,0,0,0,0,1,1), "c5c2", chunk("c5c2")),
|
("bitvector TFTFFFTTFTFFFFTT", Bitvector[16](1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1),
|
||||||
("bitlist TFTFFFTTFTFFFFTT", Bitlist[16](1,0,1,0,0,0,1,1,0,1,0,0,0,0,1,1), "c5c201", h(chunk("c5c2"), chunk("10"))),
|
"c5c2", chunk("c5c2")),
|
||||||
|
("bitlist TFTFFFTTFTFFFFTT", Bitlist[16](1, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1),
|
||||||
|
"c5c201", h(chunk("c5c2"), chunk("10"))),
|
||||||
("uint8 00", uint8(0x00), "00", chunk("00")),
|
("uint8 00", uint8(0x00), "00", chunk("00")),
|
||||||
("uint8 01", uint8(0x01), "01", chunk("01")),
|
("uint8 01", uint8(0x01), "01", chunk("01")),
|
||||||
("uint8 ab", uint8(0xab), "ab", chunk("ab")),
|
("uint8 ab", uint8(0xab), "ab", chunk("ab")),
|
||||||
|
|
Loading…
Reference in New Issue