Remove extra type definitions, add todo, use Baseclass over Union[SymbolicCalldata, ConcreteCalldata]

pull/894/head
Nikhil Parasaram 6 years ago
parent b170d74f4f
commit 36fd075836
  1. 2
      mythril/laser/ethereum/strategy/basic.py
  2. 4
      mythril/laser/ethereum/transaction/transaction_models.py
  3. 2
      mythril/laser/smt/bool.py
  4. 5
      mythril/laser/smt/expression.py

@ -14,7 +14,7 @@ except ImportError:
from random import random from random import random
from bisect import bisect from bisect import bisect
# Remove ignore after this has been fixed: https://github.com/python/mypy/issues/1297 # TODO: Remove ignore after this has been fixed: https://github.com/python/mypy/issues/1297
def choices( # type: ignore def choices( # type: ignore
population: List, weights: List[int] = None population: List, weights: List[int] = None
) -> List[int]: ) -> List[int]:

@ -87,10 +87,10 @@ class BaseTransaction:
if call_data is None and init_call_data: if call_data is None and init_call_data:
self.call_data = SymbolicCalldata( self.call_data = SymbolicCalldata(
self.id self.id
) # type: Union[SymbolicCalldata, ConcreteCalldata] ) # type: BaseCalldata
else: else:
self.call_data = ( self.call_data = (
cast(Union[SymbolicCalldata, ConcreteCalldata], call_data) call_data
if isinstance(call_data, BaseCalldata) if isinstance(call_data, BaseCalldata)
else ConcreteCalldata(self.id, []) else ConcreteCalldata(self.id, [])
) )

@ -84,7 +84,7 @@ class Bool(Expression[z3.BoolRef]):
def And(*args: Union[Bool, bool]) -> Bool: def And(*args: Union[Bool, bool]) -> Bool:
"""Create an And expression.""" """Create an And expression."""
union = [] union = []
args_list = [arg if isinstance(arg, Bool) else Bool(arg) for arg in args] # type: List[Bool] args_list = [arg if isinstance(arg, Bool) else Bool(arg) for arg in args]
for arg in args_list: for arg in args_list:
union.append(arg.annotations) union.append(arg.annotations)
return Bool(z3.And([a.raw for a in args_list]), union) return Bool(z3.And([a.raw for a in args_list]), union)

@ -46,7 +46,10 @@ class Expression(Generic[T]):
return repr(self.raw) return repr(self.raw)
def simplify(expression: T) -> T: G = TypeVar("G", bound=Expression)
def simplify(expression: G) -> G:
"""Simplify the expression . """Simplify the expression .
:param expression: :param expression:

Loading…
Cancel
Save