diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e1561f068bb8a595f3c883d5261146a94cdb4424..0d8179bc2a8f8df7daeff364f48fff582fad81f2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -20,7 +20,7 @@ repos: - id: isort args: ["--profile", "black"] - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.982 + rev: v0.990 hooks: - id: mypy - repo: https://github.com/PyCQA/pylint @@ -28,7 +28,7 @@ repos: hooks: - id: pylint - repo: https://github.com/asottile/pyupgrade - rev: v3.1.0 + rev: v3.2.2 hooks: - id: pyupgrade args: [--py37-plus] diff --git a/silkaj/auth.py b/silkaj/auth.py index ffe766d77fe6765489aec8a493fa30f17326be5b..76c55d5162f380147d44524f0c525e3aba09035d 100644 --- a/silkaj/auth.py +++ b/silkaj/auth.py @@ -22,7 +22,7 @@ from click import Context, command, confirm, option, pass_context from duniterpy.key import SigningKey from duniterpy.key.scrypt_params import ScryptParams -from silkaj.constants import PUBKEY_PATTERN +from silkaj.constants import FAILURE_EXIT_STATUS, PUBKEY_PATTERN from silkaj.public_key import gen_pubkey_checksum SEED_HEX_PATTERN = "^[0-9a-fA-F]{64}$" @@ -102,7 +102,8 @@ def auth_by_seed() -> SigningKey: # To be fixed upstream in DuniterPy # pylint: disable=broad-except except Exception as error: - sys.exit(error) + print(error) + sys.exit(FAILURE_EXIT_STATUS) @pass_context @@ -127,7 +128,8 @@ def auth_by_scrypt(ctx: Context) -> SigningKey: try: return SigningKey.from_credentials(salt, password, scrypt_params) except ValueError as error: - sys.exit(error) + print(error) + sys.exit(FAILURE_EXIT_STATUS) def auth_by_wif() -> SigningKey: @@ -140,4 +142,5 @@ def auth_by_wif() -> SigningKey: # To be fixed upstream in DuniterPy # pylint: disable=broad-except except Exception as error: - sys.exit(error) + print(error) + sys.exit(FAILURE_EXIT_STATUS) diff --git a/silkaj/blockchain/blocks.py b/silkaj/blockchain/blocks.py index ed7434aa029f275551b10183094858199f13b8a6..2805dbb485a9f47104675a64b913866eff16f3e1 100644 --- a/silkaj/blockchain/blocks.py +++ b/silkaj/blockchain/blocks.py @@ -16,7 +16,6 @@ import time from collections import OrderedDict from operator import itemgetter -from typing import List from urllib.error import HTTPError from click import IntRange, argument, command, option @@ -95,7 +94,7 @@ def print_blocks_views(issuers, current_nbr, number, detailed): print(f"\n{table.draw()}") else: - list_issued = [] # type: List[OrderedDict] + list_issued = [] for issuer in issuers: found = False for issued in list_issued: diff --git a/silkaj/money/transfer.py b/silkaj/money/transfer.py index bf93efdd09c9edb81b5f88e4276c3a964ea75675..ac0161258a39626e3f9c3c999a91cbb3eca41e21 100644 --- a/silkaj/money/transfer.py +++ b/silkaj/money/transfer.py @@ -18,7 +18,7 @@ import math import re import shlex import time -from typing import List, Tuple +from typing import List, Optional, Tuple import click from duniterpy.api.bma.tx import process @@ -408,7 +408,7 @@ def handle_intermediaries_transactions( tx_amounts: List[int], outputAddresses: List[str], Comment: str = "", - OutputbackChange: str = None, + OutputbackChange: Optional[str] = None, ) -> None: while True: # consider there is always one backchange output, hence +1 @@ -458,7 +458,7 @@ def generate_and_send_transaction( listinput_and_amount: Tuple[List[InputSource], int, bool], outputAddresses: List[str], Comment: str, - OutputbackChange: str = None, + OutputbackChange: Optional[str] = None, ) -> None: """ Display sent transaction @@ -501,7 +501,7 @@ def generate_transaction_document( listinput_and_amount: Tuple[List[InputSource], int, bool], outputAddresses: List[str], Comment: str = "", - OutputbackChange: str = None, + OutputbackChange: Optional[str] = None, ) -> Transaction: listinput = listinput_and_amount[0] diff --git a/silkaj/network.py b/silkaj/network.py index 433ec6f271292b29e9759923154fb3cb49381820..2fe1f15ce672760f5817687bed78895263c73b49 100644 --- a/silkaj/network.py +++ b/silkaj/network.py @@ -79,8 +79,9 @@ def send_document(bma_path: Any, document: Document) -> None: try: client(bma_path, document.signed_raw()) print(f"{doc_name} successfully sent") - except HTTPError as e: - sys.exit(f"Error while publishing {doc_name.lower()}: {e}") + except HTTPError as error: + print(error) + sys.exit(f"Error while publishing {doc_name.lower()}") def exit_on_http_error(error: HTTPError, err_code: int, message: str) -> None: @@ -90,4 +91,5 @@ def exit_on_http_error(error: HTTPError, err_code: int, message: str) -> None: """ if error.code == err_code: sys.exit(message) - sys.exit(error) + print(error) + sys.exit(constants.FAILURE_EXIT_STATUS) diff --git a/silkaj/tui.py b/silkaj/tui.py index 850a83e40409467c1f40b99c0c56d947022062e4..1578ea7de1bc040817c6c53306781878ca6c5c8c 100644 --- a/silkaj/tui.py +++ b/silkaj/tui.py @@ -16,7 +16,7 @@ import shutil import sys from collections import OrderedDict -from typing import Dict, List, Union +from typing import Dict, List, Optional, Union import click from texttable import Texttable @@ -42,7 +42,7 @@ class Table(Texttable): self.set_deco(self.HEADER | self.VLINES | self.BORDER) self.set_chars(VERT_TABLE_CHARS) - def fill_rows(self, rows: List[List], header: List = None) -> None: + def fill_rows(self, rows: List[List], header: Optional[List] = None) -> None: """ Fills a table from header and rows list. `rows` is a list of lists representing each row content.