From 03d73e18b21ce36cd2113ff90ec1b00fe0ce488c Mon Sep 17 00:00:00 2001 From: Nikhil Parasaram Date: Sat, 23 Mar 2019 21:36:57 +0530 Subject: [PATCH] Add typehints and docs --- mythril/analysis/report.py | 1 - mythril/support/source_support.py | 7 ++++++- mythril/support/support_utils.py | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/mythril/analysis/report.py b/mythril/analysis/report.py index 1ce5219b..44fede86 100644 --- a/mythril/analysis/report.py +++ b/mythril/analysis/report.py @@ -3,7 +3,6 @@ import logging import json import operator from jinja2 import PackageLoader, Environment - from typing import Dict, List import hashlib diff --git a/mythril/support/source_support.py b/mythril/support/source_support.py index 68d7a6aa..51d94ee8 100644 --- a/mythril/support/source_support.py +++ b/mythril/support/source_support.py @@ -48,5 +48,10 @@ class Source: else: assert False # Fail hard - def get_source_index(self, bytecode_hash): + def get_source_index(self, bytecode_hash: str) -> int: + """ + Find the contract index in the list + :param bytecode_hash: The contract hash + :return: The index of the contract in the _source_hash list + """ return self._source_hash.index(bytecode_hash) diff --git a/mythril/support/support_utils.py b/mythril/support/support_utils.py index 6912ddd3..1edbefff 100644 --- a/mythril/support/support_utils.py +++ b/mythril/support/support_utils.py @@ -26,7 +26,7 @@ class Singleton(type): return cls._instances[cls] -def get_code_hash(code): +def get_code_hash(code: str) -> str: """ :param code: bytecode :return: Returns hash of the given bytecode