Linting fixes.

This commit is contained in:
Jacques Wagener 2018-07-18 16:09:25 +02:00
parent 35c3fa0b96
commit 34dc39e916
4 changed files with 21 additions and 17 deletions

View File

@ -13,7 +13,6 @@ from web3 import (
)
from vdb.vdb import (
set_evm_opcode_debugger,
set_evm_opcode_pass,
VyperDebugCmd
)
from vdb.source_map import (
@ -47,7 +46,9 @@ def _get_contract(w3, source_code, *args, **kwargs):
stdout = kwargs['stdout'] if 'stdout' in kwargs else None
source_map = produce_source_map(source_code)
set_evm_opcode_debugger(source_code=source_code, source_map=source_map, stdin=stdin, stdout=stdout)
set_evm_opcode_debugger(
source_code=source_code, source_map=source_map, stdin=stdin, stdout=stdout
)
value = kwargs.pop('value', 0)
value_in_eth = kwargs.pop('value_in_eth', 0)
@ -76,6 +77,7 @@ def get_contract(w3):
return _get_contract(w3, source_code, *args, **kwargs)
return get_contract
@pytest.fixture
def get_last_out():
def _get_last_out(stdout):

View File

@ -34,5 +34,6 @@ def func2(a: int128):
'a': {'type': 'int128', 'size': 32, 'position': 320},
'b': {'type': 'int128', 'size': 32, 'position': 352},
'c': {'type': 'int128', 'size': 32, 'position': 384},
'g': {'type': 'bytes[10]', 'size': 96, 'position': 416}},
}
'g': {'type': 'bytes[10]', 'size': 96, 'position': 416}
},
}

View File

@ -7,6 +7,7 @@ from vyper.types import (
MappingType
)
def serialise_var_rec(var_rec):
if isinstance(var_rec.typ, ByteArrayType):
type_str = 'bytes[%s]' % var_rec.typ.maxlen
@ -27,7 +28,8 @@ def serialise_var_rec(var_rec):
def produce_source_map(code):
_contracts, _events, _defs, _globals, _custom_units = parser.get_contracts_and_defs_and_globals(parser.parse(code))
_contracts, _events, _defs, _globals, _custom_units = \
parser.get_contracts_and_defs_and_globals(parser.parse(code))
source_map = {
'globals': {},
'locals': {}

View File

@ -8,12 +8,9 @@ from evm import constants
from evm.vm.opcode import as_opcode
from evm.utils.numeric import (
int_to_big_endian,
big_endian_to_int,
# ceil32
)
from vyper.opcodes import opcodes as vyper_opcodes
commands = [
'continue',
'locals',
@ -22,10 +19,10 @@ commands = [
base_types = ('int128', 'uint256', 'address', 'bytes32')
def history():
def history(stdout):
import readline
for i in range(1, readline.get_current_history_length() + 1):
self.stdout.write("%3d %s" % (i, readline.get_history_item(i)) + '\n')
stdout.write("%3d %s" % (i, readline.get_history_item(i)) + '\n')
logo = """
@ -58,7 +55,8 @@ class VyperDebugCmd(cmd.Cmd):
prompt = '\033[92mvdb\033[0m> '
intro = logo
def __init__(self, computation, line_no=None, source_code=None, source_map=None, stdout=None, stdin=None):
def __init__(self, computation, line_no=None, source_code=None, source_map=None,
stdout=None, stdin=None):
if source_map is None:
source_map = {}
self.computation = computation
@ -116,7 +114,7 @@ class VyperDebugCmd(cmd.Cmd):
def do_locals(self, *args):
if not self.locals:
self.stdout.write('No locals found.' + '\n')
self.stdout.write('No locals found.\n')
fn_name, variables = self._get_fn_name_locals()
self.stdout.write('Function: {}'.format(fn_name) + '\n')
self.stdout.write('Name\t\tType' + '\n')
@ -140,11 +138,12 @@ class VyperDebugCmd(cmd.Cmd):
if global_type in base_types:
slot = self.globals[name]['position']
elif global_type == 'mapping':
# location_hash= keccak(int_to_big_endian(self.globals[name]['position']).rjust(32, b'\0'))
# location_hash= keccak(int_to_big_endian(
# self.globals[name]['position']).rjust(32, b'\0'))
# slot = big_endian_to_int(location_hash)
pass
else:
self.stdout.write('Can not read global of type "{}".'.format(global_type) + '\n')
self.stdout.write('Can not read global of type "{}".\n'.format(global_type))
if slot is not None:
value = self.computation.state.account_db.get_storage(
@ -160,7 +159,7 @@ class VyperDebugCmd(cmd.Cmd):
value = self.computation.memory_read(start_position, 32)
print_var(self.stdout, value, local_type)
else:
self.stdout.write('Can not read local of type ' + '\n')
self.stdout.write('Can not read local of type\n')
else:
self.stdout.write('*** Unknown syntax: %s\n' % line)
@ -169,14 +168,14 @@ class VyperDebugCmd(cmd.Cmd):
for idx, value in enumerate(self.computation._stack.values):
self.stdout.write("{}\t{}".format(idx, to_hex(value)) + '\n')
else:
self.stdout.write("Stack is empty" + '\n')
self.stdout.write("Stack is empty\n")
def do_pdb(self, *args):
# Break out to pdb for vdb debugging.
import pdb; pdb.set_trace() # noqa
def do_history(self, *args):
history()
history(self.stdout)
def emptyline(self):
pass