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

Support new mypy v0.990 reports (#453)

https://mypy-lang.blogspot.com/2022/11/mypy-0990-released.html

No Implicit Optional Types for Arguments

sys.exit() doesn't seems to handle Exception message display
where print() is not, at least for mypy

pre-commit autopdate
parent d052fc5e
No related branches found
No related tags found
1 merge request!227Support new mypy v0.990 reports
Pipeline #17664 passed
......@@ -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]
......
......@@ -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)
......@@ -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:
......
......@@ -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]
......
......@@ -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)
......@@ -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.
......
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