From 8cda959568ee47b7d811fd76e5063eb5316754b8 Mon Sep 17 00:00:00 2001 From: Moul <moul@moul.re> Date: Sun, 5 Jun 2022 16:42:54 +0200 Subject: [PATCH] [mypy] #163: Add type annotation on tui --- silkaj/tui.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/silkaj/tui.py b/silkaj/tui.py index 9afc551d..ecc407ac 100644 --- a/silkaj/tui.py +++ b/silkaj/tui.py @@ -14,6 +14,7 @@ # along with Silkaj. If not, see <https://www.gnu.org/licenses/>. import sys +from typing import List, Optional import click @@ -22,7 +23,9 @@ from silkaj import crypto_tools as ct from silkaj import wot_tools -def display_amount(tx, message, amount, ud_value, currency_symbol): +def display_amount( + tx: List, message: str, amount: float, ud_value: float, currency_symbol: str +) -> None: """ Displays an amount in unit and relative reference. """ @@ -36,7 +39,7 @@ def display_amount(tx, message, amount, ud_value, currency_symbol): ) -def display_pubkey(tx, message, pubkey): +def display_pubkey(tx: List, message: str, pubkey: str) -> None: """ Displays a pubkey and the eventually associated id. """ @@ -46,7 +49,11 @@ def display_pubkey(tx, message, pubkey): tx.append([f"{message} (id)", id["uid"]]) -def gen_pubkey_checksum(pubkey, short=False, length=constants.SHORT_PUBKEY_SIZE): +def gen_pubkey_checksum( + pubkey: str, + short: Optional[bool] = False, + length: Optional[int] = constants.SHORT_PUBKEY_SIZE, +) -> str: """ Returns "<pubkey>:<checksum>" in full form. returns `length` first chars of pubkey and checksum in short form. @@ -56,6 +63,6 @@ def gen_pubkey_checksum(pubkey, short=False, length=constants.SHORT_PUBKEY_SIZE) return f"{short_pubkey}:{ct.gen_checksum(pubkey)}" -def send_doc_confirmation(document_name): +def send_doc_confirmation(document_name: str) -> None: if not click.confirm(f"Do you confirm sending this {document_name}?"): sys.exit(constants.SUCCESS_EXIT_STATUS) -- GitLab