Skip to content
Snippets Groups Projects
Commit f528e44c authored by Moul's avatar Moul
Browse files

[mypy] #163: Add type annotation on tools and blockchain_tools

parent 7eedeb94
No related branches found
No related tags found
1 merge request!214#163: Introduce mypy
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
# along with Silkaj. If not, see <https://www.gnu.org/licenses/>. # along with Silkaj. If not, see <https://www.gnu.org/licenses/>.
import functools import functools
from typing import Dict
from duniterpy.api.bma import blockchain from duniterpy.api.bma import blockchain
...@@ -21,17 +22,17 @@ from silkaj.network_tools import client_instance ...@@ -21,17 +22,17 @@ from silkaj.network_tools import client_instance
@functools.lru_cache(maxsize=1) @functools.lru_cache(maxsize=1)
def get_blockchain_parameters(): def get_blockchain_parameters() -> Dict:
client = client_instance() client = client_instance()
return client(blockchain.parameters) return client(blockchain.parameters)
@functools.lru_cache(maxsize=1) @functools.lru_cache(maxsize=1)
def get_head_block(): def get_head_block() -> Dict:
client = client_instance() client = client_instance()
return client(blockchain.current) return client(blockchain.current)
@functools.lru_cache(maxsize=1) @functools.lru_cache(maxsize=1)
def get_currency(): def get_currency() -> str:
return get_head_block()["currency"] return get_head_block()["currency"]
...@@ -21,14 +21,13 @@ from silkaj.constants import FAILURE_EXIT_STATUS, G1_SYMBOL, GTEST_SYMBOL ...@@ -21,14 +21,13 @@ from silkaj.constants import FAILURE_EXIT_STATUS, G1_SYMBOL, GTEST_SYMBOL
@functools.lru_cache(maxsize=1) @functools.lru_cache(maxsize=1)
def get_currency_symbol(): def get_currency_symbol() -> str:
params = get_blockchain_parameters() params = get_blockchain_parameters()
if params["currency"] == "g1": if params["currency"] == "g1":
return G1_SYMBOL return G1_SYMBOL
elif params["currency"] == "g1-test": return GTEST_SYMBOL
return GTEST_SYMBOL
def message_exit(message): def message_exit(message: str) -> None:
print(message) print(message)
exit(FAILURE_EXIT_STATUS) exit(FAILURE_EXIT_STATUS)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment