diff --git a/pyproject.toml b/pyproject.toml index 0cefdc0675dd93a0bff22776addb6c9ccbabd2e1..eac5e9589795c0cb2647965c6807fd5d2fb89ec3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,5 +48,6 @@ ignore_missing_imports = true line-length = 101 target-version = "py37" select = ["W", "I", "UP", "YTT", "B", "A", "DTZ", "T10", -"EXE", "ISC", "ICN", "G", "INP", "PIE", "PYI", "Q", "RSE", "SLF", "TID", +"EXE", "ISC", "ICN", "G", "INP", "PIE", "PYI", "Q", "RSE", "SLF", "TID", "PL", "COM", "C4", "PT", "RET", "SIM", "PTH", "PGH", "PL", "TRY", "RUF"] +ignore = ["PLR2004", "PLR0913"] diff --git a/silkaj/checksum.py b/silkaj/checksum.py index beb173c226a478fb24c8dedadd75e5c613d4c808..0e81d11102d263a368cd6220c480dfca616faead 100644 --- a/silkaj/checksum.py +++ b/silkaj/checksum.py @@ -39,16 +39,15 @@ def checksum_command(pubkey_checksum: str) -> None: if has_auth_method(): key = auth_method() click.echo(gen_pubkey_checksum(key.pubkey)) - else: - if not pubkey_checksum: - sys.exit(MESSAGE) - elif re.search(re.compile(PUBKEY_DELIMITED_PATTERN), pubkey_checksum[0]): - click.echo(gen_pubkey_checksum(pubkey_checksum[0])) - elif re.search(re.compile(PUBKEY_CHECKSUM_PATTERN), pubkey_checksum[0]): - pubkey, checksum = pubkey_checksum[0].split(":") - if checksum == gen_checksum(pubkey): - click.echo("The checksum is valid") - else: - click.echo("The checksum is invalid") + elif not pubkey_checksum: + sys.exit(MESSAGE) + elif re.search(re.compile(PUBKEY_DELIMITED_PATTERN), pubkey_checksum[0]): + click.echo(gen_pubkey_checksum(pubkey_checksum[0])) + elif re.search(re.compile(PUBKEY_CHECKSUM_PATTERN), pubkey_checksum[0]): + pubkey, checksum = pubkey_checksum[0].split(":") + if checksum == gen_checksum(pubkey): + click.echo("The checksum is valid") else: - sys.exit("Error: Wrong public key format") + click.echo("The checksum is invalid") + else: + sys.exit("Error: Wrong public key format") diff --git a/silkaj/money/transfer.py b/silkaj/money/transfer.py index ca821d3b99a6674ecb9c6e668ca035ad3100c35f..99473f9230d2e4c567016f3732488e38b73b2819 100644 --- a/silkaj/money/transfer.py +++ b/silkaj/money/transfer.py @@ -265,7 +265,7 @@ def transaction_amount( # In case one amount is passed with multiple recipients # generate list containing multiple time the same amount if len(amounts_list) == 1 and len(outputAddresses) > 1: - amounts_list = [amounts_list[0]] * len(outputAddresses) + return [amounts_list[0]] * len(outputAddresses) return amounts_list diff --git a/silkaj/tools.py b/silkaj/tools.py index 88c51e61710886ee4f9624d77ffa3180e3fa779f..1ef2a719a47537544f5c121f95265f99d49e4187 100644 --- a/silkaj/tools.py +++ b/silkaj/tools.py @@ -52,7 +52,7 @@ class MutuallyExclusiveOption(click.Option): if self.mutually_exclusive.intersection(opts) and self.name in opts: arguments = ", ".join(self.mutually_exclusive) raise click.UsageError( - f"Usage: `{self.name}` is mutually exclusive with arguments `{arguments}`.", + message=f"Usage: `{self.name}` is mutually exclusive with arguments `{arguments}`.", ) return super().handle_parse_result(ctx, opts, args) diff --git a/silkaj/wot/tools.py b/silkaj/wot/tools.py index 1899f0d61093607da87b54d650440235b99e7c32..ce36406ac65d84bdf3376c975fb0e03493184a64 100644 --- a/silkaj/wot/tools.py +++ b/silkaj/wot/tools.py @@ -13,6 +13,7 @@ # You should have received a copy of the GNU Affero General Public License # along with Silkaj. If not, see <https://www.gnu.org/licenses/>. +import contextlib import time import urllib from typing import Dict, List, Optional, Tuple @@ -70,10 +71,8 @@ def identities_from_pubkeys(pubkeys: List[str], uids: bool) -> List: identities = [] for pubkey in uniq_pubkeys: time.sleep(BMA_SLEEP) - try: + with contextlib.suppress(HTTPError): identities.append(identity_of(pubkey)) - except HTTPError: - pass return identities diff --git a/tests/unit/money/test_transfer_cli.py b/tests/unit/money/test_transfer_cli.py index 780a7b7c8450b53883d6bcd1fead1a36615710b6..021a14c6945f6004775a8213d2600cd9f6951082 100644 --- a/tests/unit/money/test_transfer_cli.py +++ b/tests/unit/money/test_transfer_cli.py @@ -118,7 +118,7 @@ def test_transaction_amount_errors( monkeypatch.setattr(m_tools, "get_ud_value", patched_get_ud_value) # check program exit on error - with pytest.raises(SystemExit) as pytest_exit: + with pytest.raises(SystemExit) as pytest_exit: # noqa: PT012 # read output to check error. transfer.transaction_amount(amounts, UDs_amounts, outputAddresses) assert expected == capsys.readouterr() diff --git a/tests/unit/test_public_key.py b/tests/unit/test_public_key.py index 0dfeb236a7b7aef47770fa3ad5df00053f39d4ac..0aa117a6f8661c45bf814701e0ae9f7e52be366e 100644 --- a/tests/unit/test_public_key.py +++ b/tests/unit/test_public_key.py @@ -110,7 +110,7 @@ J4c8CARmP9vAFNGtHRuzx14zvxojyRWHW2darguVqjtX", ], ) def test_is_pubkey_and_check_errors(uid_pubkey, expected, capsys): - with pytest.raises(SystemExit) as pytest_exit: + with pytest.raises(SystemExit) as pytest_exit: # noqa: PT012 public_key.is_pubkey_and_check(uid_pubkey) assert capsys.readouterr() == expected assert pytest_exit.type == SystemExit