support list casting
This commit is contained in:
parent
dd5ad2e2c5
commit
e873bbd73b
|
@ -296,7 +296,7 @@ class BaseList(list, Elements):
|
|||
@classmethod
|
||||
def extract_args(cls, *args):
|
||||
x = list(args)
|
||||
if len(x) == 1 and isinstance(x[0], GeneratorType):
|
||||
if len(x) == 1 and isinstance(x[0], (GeneratorType, list, tuple)):
|
||||
x = list(x[0])
|
||||
x = [coerce_type_maybe(v, cls.elem_type) for v in x]
|
||||
return x
|
||||
|
|
|
@ -161,6 +161,8 @@ def test_list():
|
|||
assert issubclass(v.type(), Elements)
|
||||
assert isinstance(v.type(), ElementsType)
|
||||
|
||||
assert len(typ([i for i in range(10)])) == 10 # cast py list to SSZ list
|
||||
|
||||
foo = List[uint32, 128](0 for i in range(128))
|
||||
foo[0] = 123
|
||||
foo[1] = 654
|
||||
|
|
Loading…
Reference in New Issue