Skip to content

Commit

Permalink
lint: run black
Browse files Browse the repository at this point in the history
  • Loading branch information
fubuloubu committed Mar 7, 2021
1 parent 06dc5b8 commit a8a6528
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 21 deletions.
4 changes: 1 addition & 3 deletions ethervm.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,4 @@ def convert_to_string(o):
else:
return str(o)

return "\n".join(
convert_to_string(o) for o in disassemble(evm_opcodes[evm_version], bytecode)
)
return "\n".join(convert_to_string(o) for o in disassemble(evm_opcodes[evm_version], bytecode))
10 changes: 2 additions & 8 deletions evm_asm/assembler.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,7 @@ def assemble(evm: Fork, assembly: Assembly) -> Bytecode:
last_opcode = None
for code in assembly_iter:
# Check if string literals or metadata included after end of code
if (
isinstance(code, bytes)
and last_opcode
and last_opcode.opcode_value in END_OPCODES
):
if isinstance(code, bytes) and last_opcode and last_opcode.opcode_value in END_OPCODES:
if len(code) > 0:
bytecode.extend(code)
continue # These are special cases
Expand Down Expand Up @@ -137,9 +133,7 @@ def _split_string_literals(bytecode: Bytecode) -> Tuple[Bytecode, bytes]:
return Bytecode(bytecode[:last_stopcode_idx]), bytecode[last_stopcode_idx:]


def disassemble(
evm: Fork, bytecode: Bytecode, include_metadata: bool = True
) -> Assembly:
def disassemble(evm: Fork, bytecode: Bytecode, include_metadata: bool = True) -> Assembly:
bytecode, metadata = _split_metadata(bytecode)
bytecode, string_literals = _split_string_literals(bytecode)

Expand Down
4 changes: 1 addition & 3 deletions evm_asm/forks/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ def __getitem__(self, fork_name: str) -> Fork:
if fork_name in forks:
return getattr(self, fork_name.upper())

raise TypeError(
f"'{fork_name}' is not a valid fork name, must be one of '{forks}'"
)
raise TypeError(f"'{fork_name}' is not a valid fork name, must be one of '{forks}'")


evm_opcodes = EvmForks()
Expand Down
4 changes: 1 addition & 3 deletions evm_asm/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ def serialize(self, input_value: Optional[int] = None) -> Bytecode:
input_bytes = b""
if self.input_size_bytes > 0:
assert input_value, "Must have value"
assert (
0 <= input_value < 2 ** self.input_size_bytes
), "Value outside of range"
assert 0 <= input_value < 2 ** self.input_size_bytes, "Value outside of range"
input_bytes = input_value.to_bytes(self.input_size_bytes, "little")

return Bytecode(bytes(self.opcode_value) + input_bytes)
Expand Down
5 changes: 1 addition & 4 deletions tools/fork_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,7 @@
lines = 0
for opcode, props in value.items():
mnemonic = props.mnemonic.upper()
if (
mnemonic not in used_opcodes.keys()
or used_opcodes[mnemonic] != props.gas_cost
):
if mnemonic not in used_opcodes.keys() or used_opcodes[mnemonic] != props.gas_cost:
print(
f' {mnemonic} = Opcode("{mnemonic}", {props.gas_cost}, {"0x{:02X}".format(opcode)})'
)
Expand Down

0 comments on commit a8a6528

Please sign in to comment.