Add `BaseBytes` to cover `Bytes` and `BytesN`

This commit is contained in:
Hsiao-Wei Wang 2019-08-20 19:21:12 +08:00
parent 6577f159c9
commit d6bbd9bfa1
No known key found for this signature in database
GPG Key ID: 95B070122902DEA4
2 changed files with 3 additions and 2 deletions

View File

@ -54,7 +54,7 @@ from eth2spec.utils.ssz.ssz_impl import (
is_zero,
)
from eth2spec.utils.ssz.ssz_typing import (
BasicValue, Elements, BaseList, SSZType,
BasicValue, Elements, BaseBytes, BaseList, SSZType,
Container, List, Vector, Bytes, BytesN, Bitlist, Bitvector, Bits,
Bytes1, Bytes4, Bytes8, Bytes32, Bytes48, Bytes96,
uint64, bit, boolean,

View File

@ -106,7 +106,8 @@ def item_length(typ: SSZType) -> int:
```
```python
def get_elem_type(typ: Union[BaseList, Container], index_or_variable_name: Union[int, SSZVariableName]) -> SSZType:
def get_elem_type(typ: Union[BaseBytes, BaseList, Container],
index_or_variable_name: Union[int, SSZVariableName]) -> SSZType:
"""
Return the type of the element of an object of the given type with the given index
or member variable name (eg. `7` for `x[7]`, `"foo"` for `x.foo`)