From b7a625af25a8b280dfa5011c01ab0b8744de7731 Mon Sep 17 00:00:00 2001 From: Hugo Herter Date: Wed, 25 Jan 2023 16:25:50 +0100 Subject: [PATCH] Cleanup --- src/aleph_client/chains/cosmos.py | 3 +- src/aleph_client/chains/ethereum.py | 8 +++-- src/aleph_client/chains/nuls1.py | 8 +++-- src/aleph_client/chains/nuls2.py | 18 +++++++--- src/aleph_client/chains/tezos.py | 3 +- src/aleph_client/commands/program.py | 18 +++++++--- src/aleph_client/user_session.py | 50 ++++++++++++++++++++------- src/aleph_client/vm/app.py | 12 +++++-- tests/unit/test_asynchronous.py | 9 +++-- tests/unit/test_chain_nuls1_compat.py | 3 +- tests/unit/test_utils.py | 10 ++++-- 11 files changed, 104 insertions(+), 38 deletions(-) diff --git a/src/aleph_client/chains/cosmos.py b/src/aleph_client/chains/cosmos.py index 1a548531..43dcd0a6 100644 --- a/src/aleph_client/chains/cosmos.py +++ b/src/aleph_client/chains/cosmos.py @@ -5,8 +5,7 @@ import ecdsa from cosmospy._wallet import privkey_to_address, privkey_to_pubkey -from .common import (BaseAccount, get_fallback_private_key, - get_verification_buffer) +from .common import BaseAccount, get_fallback_private_key, get_verification_buffer DEFAULT_HRP = "cosmos" diff --git a/src/aleph_client/chains/ethereum.py b/src/aleph_client/chains/ethereum.py index 961a5bae..f16bf448 100644 --- a/src/aleph_client/chains/ethereum.py +++ b/src/aleph_client/chains/ethereum.py @@ -5,8 +5,12 @@ from eth_account.messages import encode_defunct from eth_account.signers.local import LocalAccount -from .common import (BaseAccount, get_fallback_private_key, get_public_key, - get_verification_buffer) +from .common import ( + BaseAccount, + get_fallback_private_key, + get_public_key, + get_verification_buffer, +) class ETHAccount(BaseAccount): diff --git a/src/aleph_client/chains/nuls1.py b/src/aleph_client/chains/nuls1.py index 4949d75d..eebc5738 100644 --- a/src/aleph_client/chains/nuls1.py +++ b/src/aleph_client/chains/nuls1.py @@ -8,8 +8,12 @@ from coincurve.keys import PrivateKey, PublicKey -from .common import (BaseAccount, get_fallback_private_key, get_public_key, - get_verification_buffer) +from .common import ( + BaseAccount, + get_fallback_private_key, + get_public_key, + get_verification_buffer, +) LOGGER = logging.getLogger("NULS") diff --git a/src/aleph_client/chains/nuls2.py b/src/aleph_client/chains/nuls2.py index 852911d9..71841d99 100644 --- a/src/aleph_client/chains/nuls2.py +++ b/src/aleph_client/chains/nuls2.py @@ -1,10 +1,18 @@ import base64 -from nuls2.model.data import (NETWORKS, address_from_hash, public_key_to_hash, - sign_recoverable_message) - -from .common import (BaseAccount, get_fallback_private_key, get_public_key, - get_verification_buffer) +from nuls2.model.data import ( + NETWORKS, + address_from_hash, + public_key_to_hash, + sign_recoverable_message, +) + +from .common import ( + BaseAccount, + get_fallback_private_key, + get_public_key, + get_verification_buffer, +) def get_address(public_key=None, private_key=None, chain_id=1, prefix="NULS"): diff --git a/src/aleph_client/chains/tezos.py b/src/aleph_client/chains/tezos.py index 4d0ddb12..4d3bc697 100644 --- a/src/aleph_client/chains/tezos.py +++ b/src/aleph_client/chains/tezos.py @@ -6,8 +6,7 @@ from nacl.public import SealedBox from nacl.signing import SigningKey -from .common import (BaseAccount, get_fallback_private_key, - get_verification_buffer) +from .common import BaseAccount, get_fallback_private_key, get_verification_buffer class TezosAccount(BaseAccount): diff --git a/src/aleph_client/commands/program.py b/src/aleph_client/commands/program.py index 4ad5aa46..d6ee3017 100644 --- a/src/aleph_client/commands/program.py +++ b/src/aleph_client/commands/program.py @@ -6,15 +6,23 @@ from zipfile import BadZipFile import typer -from aleph_message.models import (MessagesResponse, ProgramContent, - ProgramMessage, StoreMessage) +from aleph_message.models import ( + MessagesResponse, + ProgramContent, + ProgramMessage, + StoreMessage, +) from aleph_client import AuthenticatedUserSession from aleph_client.account import _load_account from aleph_client.commands import help_strings -from aleph_client.commands.utils import (input_multiline, prompt_for_volumes, - setup_logging, volume_to_dict, - yes_no_input) +from aleph_client.commands.utils import ( + input_multiline, + prompt_for_volumes, + setup_logging, + volume_to_dict, + yes_no_input, +) from aleph_client.conf import settings from aleph_client.types import AccountFromPrivateKey, StorageEnum from aleph_client.utils import create_archive diff --git a/src/aleph_client/user_session.py b/src/aleph_client/user_session.py index f53af4f4..59064c18 100644 --- a/src/aleph_client/user_session.py +++ b/src/aleph_client/user_session.py @@ -7,25 +7,51 @@ import time from datetime import datetime from pathlib import Path -from typing import (Any, AsyncIterable, Awaitable, Callable, Dict, Iterable, - List, Mapping, NoReturn, Optional, Tuple, Type, TypeVar, - Union) +from typing import ( + Any, + AsyncIterable, + Awaitable, + Callable, + Dict, + Iterable, + List, + Mapping, + NoReturn, + Optional, + Tuple, + Type, + TypeVar, + Union, +) import aiohttp -from aleph_message.models import (AggregateContent, AggregateMessage, - AlephMessage, ForgetContent, ForgetMessage, - ItemType, Message, MessageType, PostContent, - PostMessage, ProgramMessage, StoreContent, - StoreMessage) +from aleph_message.models import ( + AggregateContent, + AggregateMessage, + AlephMessage, + ForgetContent, + ForgetMessage, + ItemType, + Message, + MessageType, + PostContent, + PostMessage, + ProgramMessage, + StoreContent, + StoreMessage, +) from aleph_message.models.program import Encoding, ProgramContent from pydantic import ValidationError -from aleph_client.types import (Account, GenericMessage, MessageStatus, - StorageEnum) +from aleph_client.types import Account, GenericMessage, MessageStatus, StorageEnum from .conf import settings -from .exceptions import (BroadcastError, InvalidMessageError, - MessageNotFoundError, MultipleMessagesError) +from .exceptions import ( + BroadcastError, + InvalidMessageError, + MessageNotFoundError, + MultipleMessagesError, +) from .models import MessagesResponse from .utils import get_message_type_value diff --git a/src/aleph_client/vm/app.py b/src/aleph_client/vm/app.py index 5467b2a4..0077885e 100644 --- a/src/aleph_client/vm/app.py +++ b/src/aleph_client/vm/app.py @@ -1,6 +1,14 @@ from dataclasses import dataclass -from typing import (Any, Awaitable, Callable, Dict, List, Mapping, - MutableMapping, Optional) +from typing import ( + Any, + Awaitable, + Callable, + Dict, + List, + Mapping, + MutableMapping, + Optional, +) AsgiApplication = Callable diff --git a/tests/unit/test_asynchronous.py b/tests/unit/test_asynchronous.py index 5c81003e..de4b5963 100644 --- a/tests/unit/test_asynchronous.py +++ b/tests/unit/test_asynchronous.py @@ -2,8 +2,13 @@ from unittest.mock import AsyncMock, MagicMock import pytest as pytest -from aleph_message.models import (AggregateMessage, ForgetMessage, PostMessage, - ProgramMessage, StoreMessage) +from aleph_message.models import ( + AggregateMessage, + ForgetMessage, + PostMessage, + ProgramMessage, + StoreMessage, +) from aleph_client import AuthenticatedUserSession from aleph_client.types import Account, MessageStatus, StorageEnum diff --git a/tests/unit/test_chain_nuls1_compat.py b/tests/unit/test_chain_nuls1_compat.py index 5957a3e4..65869162 100644 --- a/tests/unit/test_chain_nuls1_compat.py +++ b/tests/unit/test_chain_nuls1_compat.py @@ -10,8 +10,7 @@ from coincurve.keys import PrivateKey from aleph_client.chains.common import get_fallback_private_key -from aleph_client.chains.nuls1 import (LOGGER, MESSAGE_TEMPLATE, NulsSignature, - VarInt) +from aleph_client.chains.nuls1 import LOGGER, MESSAGE_TEMPLATE, NulsSignature, VarInt SECRET = ( b"\xc4\xfe\xe65\x96\x14\xb4:\r: \x05;\x12j\x9bJ" diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py index 1a40936a..0671bf24 100644 --- a/tests/unit/test_utils.py +++ b/tests/unit/test_utils.py @@ -1,5 +1,11 @@ -from aleph_message.models import (AggregateMessage, ForgetMessage, MessageType, - PostMessage, ProgramMessage, StoreMessage) +from aleph_message.models import ( + AggregateMessage, + ForgetMessage, + MessageType, + PostMessage, + ProgramMessage, + StoreMessage, +) from aleph_client.utils import get_message_type_value