Fix __getitem__ signature hints

pull/632/head
Dominik Muhs 6 years ago
parent 5167274644
commit a144c5a50d
  1. 9
      mythril/laser/ethereum/state.py

@ -2,7 +2,6 @@ from z3 import (
BitVec, BitVec,
BitVecVal, BitVecVal,
BitVecRef, BitVecRef,
BitVecNumRef,
BitVecSort, BitVecSort,
Solver, Solver,
ExprRef, ExprRef,
@ -21,7 +20,7 @@ from mythril.laser.ethereum.cfg import Node
from copy import copy, deepcopy from copy import copy, deepcopy
from enum import Enum from enum import Enum
from random import randint from random import randint
from typing import KeysView, Dict, List, Union, Any from typing import KeysView, Dict, List, Union, Any, Sequence
from mythril.laser.ethereum.util import get_concrete_int from mythril.laser.ethereum.util import get_concrete_int
from mythril.laser.ethereum.evm_exceptions import ( from mythril.laser.ethereum.evm_exceptions import (
@ -89,7 +88,7 @@ class Calldata:
def get_word_at(self, index: int): def get_word_at(self, index: int):
return self[index : index + 32] return self[index : index + 32]
def __getitem__(self, item): def __getitem__(self, item: Union[int, slice]) -> Any:
if isinstance(item, slice): if isinstance(item, slice):
try: try:
current_index = ( current_index = (
@ -130,7 +129,7 @@ class Storage:
self.dynld = dynamic_loader self.dynld = dynamic_loader
self.address = address self.address = address
def __getitem__(self, item: int) -> int: def __getitem__(self, item: Union[int, slice]) -> Any:
try: try:
return self._storage[item] return self._storage[item]
except KeyError: except KeyError:
@ -296,7 +295,7 @@ class MachineStack(list):
except IndexError: except IndexError:
raise StackUnderflowException("Trying to pop from an empty stack") raise StackUnderflowException("Trying to pop from an empty stack")
def __getitem__(self, item: int) -> Any: def __getitem__(self, item: Union[int, slice]) -> Any:
try: try:
return super(MachineStack, self).__getitem__(item) return super(MachineStack, self).__getitem__(item)
except IndexError: except IndexError:

Loading…
Cancel
Save