fix pyspec lint

This commit is contained in:
Hsiao-Wei Wang 2019-05-09 14:25:08 +08:00
parent a4ba283d67
commit 84472a5a6e
No known key found for this signature in database
GPG Key ID: 95B070122902DEA4
2 changed files with 10 additions and 3 deletions

View File

@ -22,6 +22,8 @@ from eth2spec.utils.bls_stub import (
bls_verify,
bls_verify_multiple,
)
from eth2spec.utils.hash_function import hash
# stub, will get overwritten by real var
SLOTS_PER_EPOCH = 64
@ -69,6 +71,7 @@ def hash(x):
hash_cache[x] = ret
return ret
# Access to overwrite spec constants based on configuration
def apply_constants_preset(preset: Dict[str, Any]):
global_vars = globals()

View File

@ -55,15 +55,19 @@ def get_spec(file_name: str) -> List[str]:
if eligible:
code_lines.append(row[0] + ' = ' + (row[1].replace('**TBD**', '0x1234567890123456789012345678901234567890')))
# Build type-def re-initialization
code_lines.append('')
code_lines.append('\n')
code_lines.append('def init_SSZ_types():')
code_lines.append(' global_vars = globals()')
for ssz_type_name, ssz_type in type_defs:
code_lines.append('')
for type_line in ssz_type:
if len(type_line) > 0:
code_lines.append(' ' + type_line)
code_lines.append('\n')
code_lines.append('ssz_types = [' + ', '.join([f'\'{ssz_type_name}\'' for (ssz_type_name, _) in type_defs]) + ']')
code_lines.append('ssz_types = [\n')
for (ssz_type_name, _) in type_defs:
code_lines.append(f' {ssz_type_name},\n')
code_lines.append(']')
code_lines.append('\n')
code_lines.append('def get_ssz_type_by_name(name: str) -> SSZType:')
code_lines.append(' return globals()[name]')