diff --git a/duniterpy/api/bma/__init__.py b/duniterpy/api/bma/__init__.py index 18fee245c53c2632cf70c5264f42c60d29e8e10a..80ff06293c02c45bc5975422198b68f00bb987d8 100644 --- a/duniterpy/api/bma/__init__.py +++ b/duniterpy/api/bma/__init__.py @@ -14,7 +14,8 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. import logging -from . import network, blockchain, tx, wot, node, ud, ws + +from . import blockchain, network, node, tx, ud, wot, ws __all__ = ["network", "blockchain", "tx", "wot", "node", "ud", "ws"] diff --git a/duniterpy/api/bma/blockchain.py b/duniterpy/api/bma/blockchain.py index c0e26c2c424f90ef6b37fa093409836777576da2..2357755e82e485896480a08930c7500d34908a13 100644 --- a/duniterpy/api/bma/blockchain.py +++ b/duniterpy/api/bma/blockchain.py @@ -14,11 +14,10 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. import logging -from typing import Union - from http.client import HTTPResponse +from typing import Union -from duniterpy.api.client import Client, RESPONSE_HTTP +from duniterpy.api.client import RESPONSE_HTTP, Client logger = logging.getLogger("duniter/blockchain") diff --git a/duniterpy/api/bma/network.py b/duniterpy/api/bma/network.py index eb8f6176e4fa2b0849691e531e6be802216dc1a1..581264bb230a7bf6b646c297ad31d3853667b8fb 100644 --- a/duniterpy/api/bma/network.py +++ b/duniterpy/api/bma/network.py @@ -14,10 +14,9 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. import logging - from http.client import HTTPResponse -from duniterpy.api.client import Client, RESPONSE_HTTP +from duniterpy.api.client import RESPONSE_HTTP, Client logger = logging.getLogger("duniter/network") diff --git a/duniterpy/api/bma/tx.py b/duniterpy/api/bma/tx.py index abbab2d570a8196fff19d315dfb4583c6db0b3ff..b46cf62cdc9fbb3683758c3f81b43c9408845ed4 100644 --- a/duniterpy/api/bma/tx.py +++ b/duniterpy/api/bma/tx.py @@ -14,10 +14,9 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. import logging - from http.client import HTTPResponse -from duniterpy.api.client import Client, RESPONSE_HTTP +from duniterpy.api.client import RESPONSE_HTTP, Client logger = logging.getLogger("duniter/tx") diff --git a/duniterpy/api/bma/wot.py b/duniterpy/api/bma/wot.py index 64946f47464195b2202853d6a6030951ab587e27..56c8d2802aff0dc0907b5afdf075937886163982 100644 --- a/duniterpy/api/bma/wot.py +++ b/duniterpy/api/bma/wot.py @@ -14,10 +14,9 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. import logging - from http.client import HTTPResponse -from duniterpy.api.client import Client, RESPONSE_HTTP +from duniterpy.api.client import RESPONSE_HTTP, Client logger = logging.getLogger("duniter/wot") diff --git a/duniterpy/api/client.py b/duniterpy/api/client.py index fe0233571e7edad5e9af237d03c157cac48ff269..c53d1808bba620e2fe8345a3b60f761191991e52 100644 --- a/duniterpy/api/client.py +++ b/duniterpy/api/client.py @@ -16,14 +16,15 @@ import copy import json import logging -from typing import Callable, Union, Any, Optional, Dict -from urllib import request, parse +from http.client import HTTPResponse +from typing import Any, Callable, Dict, Optional, Union +from urllib import parse, request import jsonschema from websocket import WebSocket -from http.client import HTTPResponse from duniterpy.api import endpoint + from .errors import DuniterError logger = logging.getLogger("duniter") diff --git a/duniterpy/api/endpoint.py b/duniterpy/api/endpoint.py index c0198cc80b44eb7055cbfc22c563c09f28425f26..f8288382d38b9a04fad5012ccbb03901cdca90c4 100644 --- a/duniterpy/api/endpoint.py +++ b/duniterpy/api/endpoint.py @@ -14,9 +14,10 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. import re -from typing import Any, Optional, TypeVar, Type, Dict +from typing import Any, Dict, Optional, Type, TypeVar from duniterpy import constants + from ..documents import MalformedDocumentError diff --git a/duniterpy/api/ws2p/__init__.py b/duniterpy/api/ws2p/__init__.py index 3404cf04731273d9a3d5c466f2767ea25af8a928..3557948d0d32b31cb7a22e6b96d1ba6ba89b9bcd 100644 --- a/duniterpy/api/ws2p/__init__.py +++ b/duniterpy/api/ws2p/__init__.py @@ -14,6 +14,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. import logging + from . import network, requests __all__ = ["network", "requests"] diff --git a/duniterpy/api/ws2p/requests.py b/duniterpy/api/ws2p/requests.py index 0075ca3e678f95dd7802e53ab9353739098d83f7..8c406f7019f63ae1973e0e7e0270f7faf8143e96 100644 --- a/duniterpy/api/ws2p/requests.py +++ b/duniterpy/api/ws2p/requests.py @@ -15,6 +15,7 @@ import json import re + from duniterpy.api.bma.blockchain import BLOCK_SCHEMA, BLOCKS_SCHEMA ERROR_RESPONSE_SCHEMA = { diff --git a/duniterpy/documents/__init__.py b/duniterpy/documents/__init__.py index 6422cae317a736fb44d13b02cc9155b532e8ae83..b9fe552ae48b5416127da5e4473e22151ce49604 100644 --- a/duniterpy/documents/__init__.py +++ b/duniterpy/documents/__init__.py @@ -15,18 +15,18 @@ from .block import Block from .block_uid import BlockUID, block_uid -from .document import Document, MalformedDocumentError from .certification import Certification -from .revocation import Revocation +from .crc_pubkey import CRCPubkey +from .document import Document, MalformedDocumentError from .identity import Identity from .membership import Membership +from .revocation import Revocation from .transaction import ( - SimpleTransaction, - Transaction, InputSource, OutputSource, SIGParameter, + SimpleTransaction, + Transaction, Unlock, UnlockParameter, ) -from .crc_pubkey import CRCPubkey diff --git a/duniterpy/documents/block.py b/duniterpy/documents/block.py index 6e11e20e48f239f14685da181026125a97d17ccd..70061828e4c40287d343bd3e5171ea1e345a791f 100644 --- a/duniterpy/documents/block.py +++ b/duniterpy/documents/block.py @@ -16,16 +16,16 @@ import base64 import hashlib import re -from typing import TypeVar, Type, Optional, List, Sequence +from typing import List, Optional, Sequence, Type, TypeVar + +from ..constants import BLOCK_HASH_REGEX, PUBKEY_REGEX from .block_uid import BlockUID from .certification import Certification -from .revocation import Revocation -from .identity import Identity from .document import Document, MalformedDocumentError +from .identity import Identity from .membership import Membership +from .revocation import Revocation from .transaction import Transaction -from ..constants import PUBKEY_REGEX, BLOCK_HASH_REGEX - # required to type hint cls in classmethod BlockType = TypeVar("BlockType", bound="Block") diff --git a/duniterpy/documents/block_uid.py b/duniterpy/documents/block_uid.py index 3974c0039c1ad8698b6d81faba36eaec1da42168..3707b27f2615cecefdb8f7553fed8ab099935e67 100644 --- a/duniterpy/documents/block_uid.py +++ b/duniterpy/documents/block_uid.py @@ -14,10 +14,10 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. import re -from typing import Union, TypeVar, Type +from typing import Type, TypeVar, Union +from ..constants import BLOCK_HASH_REGEX, BLOCK_ID_REGEX, EMPTY_HASH from .document import MalformedDocumentError -from ..constants import EMPTY_HASH, BLOCK_ID_REGEX, BLOCK_HASH_REGEX # required to type hint cls in classmethod BlockUIDType = TypeVar("BlockUIDType", bound="BlockUID") diff --git a/duniterpy/documents/certification.py b/duniterpy/documents/certification.py index 78afe66b1aa392729dba32dbcaa05f0f615c7894..ede06b5420cc92689f7df497488d161aea22447a 100644 --- a/duniterpy/documents/certification.py +++ b/duniterpy/documents/certification.py @@ -16,19 +16,18 @@ import base64 import logging import re -from typing import Optional, TypeVar, Type, Union +from typing import Optional, Type, TypeVar, Union -from .identity import Identity -from .block_uid import BlockUID from ..constants import ( - PUBKEY_REGEX, - SIGNATURE_REGEX, BLOCK_ID_REGEX, BLOCK_UID_REGEX, + PUBKEY_REGEX, + SIGNATURE_REGEX, UID_REGEX, ) +from .block_uid import BlockUID from .document import Document, MalformedDocumentError - +from .identity import Identity # required to type hint cls in classmethod CertificationType = TypeVar("CertificationType", bound="Certification") diff --git a/duniterpy/documents/crc_pubkey.py b/duniterpy/documents/crc_pubkey.py index fb2a7c72cc52d94751c33d9a8add6ca2a7d2b8c6..0a5b0c503cec7ba215ebeea07b5cfe6301f333a6 100644 --- a/duniterpy/documents/crc_pubkey.py +++ b/duniterpy/documents/crc_pubkey.py @@ -13,11 +13,12 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -from typing import TypeVar, Type +import hashlib +import re +from typing import Type, TypeVar import base58 -import re -import hashlib + from ..constants import PUBKEY_REGEX from ..tools import ensure_str diff --git a/duniterpy/documents/document.py b/duniterpy/documents/document.py index 136b0433584d489903301cb4fc0ef7b32c7e8302..f089032875639f47099ab9d319dfb2e92020ce45 100644 --- a/duniterpy/documents/document.py +++ b/duniterpy/documents/document.py @@ -17,7 +17,7 @@ import base64 import hashlib import logging import re -from typing import TypeVar, Type, Any, List +from typing import Any, List, Type, TypeVar from ..constants import SIGNATURE_REGEX diff --git a/duniterpy/documents/identity.py b/duniterpy/documents/identity.py index 07b456ce405eab9a4fbb7c0042bdb1e14ab792ed..3bc878b309ba2e560d27f36cef6e8cf04d7781bb 100644 --- a/duniterpy/documents/identity.py +++ b/duniterpy/documents/identity.py @@ -14,10 +14,10 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. import re -from typing import Optional, TypeVar, Type +from typing import Optional, Type, TypeVar +from ..constants import BLOCK_UID_REGEX, PUBKEY_REGEX, SIGNATURE_REGEX, UID_REGEX from .block_uid import BlockUID -from ..constants import PUBKEY_REGEX, SIGNATURE_REGEX, BLOCK_UID_REGEX, UID_REGEX from .document import Document, MalformedDocumentError # required to type hint cls in classmethod diff --git a/duniterpy/documents/membership.py b/duniterpy/documents/membership.py index 2573d07738d49c82d18ed1c3277b9bad96d7d58c..d79c79d5c0d6de0e549ae3d7171a6ebce07153f1 100644 --- a/duniterpy/documents/membership.py +++ b/duniterpy/documents/membership.py @@ -14,11 +14,11 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. import re -from typing import TypeVar, Type, Optional +from typing import Optional, Type, TypeVar +from ..constants import BLOCK_UID_REGEX, PUBKEY_REGEX, SIGNATURE_REGEX from .block_uid import BlockUID from .document import Document, MalformedDocumentError -from ..constants import BLOCK_UID_REGEX, SIGNATURE_REGEX, PUBKEY_REGEX # required to type hint cls in classmethod MembershipType = TypeVar("MembershipType", bound="Membership") diff --git a/duniterpy/documents/peer.py b/duniterpy/documents/peer.py index b6f13799786a93a5df725dba37bede6fadbf02b6..b5bb076f1d80fdcb29ab65ad2054e8320a7c4b86 100644 --- a/duniterpy/documents/peer.py +++ b/duniterpy/documents/peer.py @@ -14,12 +14,13 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. import re -from typing import TypeVar, List, Type +from typing import List, Type, TypeVar + +from duniterpy.api.endpoint import Endpoint, endpoint -from duniterpy.api.endpoint import endpoint, Endpoint -from .document import Document, MalformedDocumentError -from .block_uid import BlockUID from ..constants import BLOCK_HASH_REGEX, PUBKEY_REGEX +from .block_uid import BlockUID +from .document import Document, MalformedDocumentError # required to type hint cls in classmethod PeerType = TypeVar("PeerType", bound="Peer") diff --git a/duniterpy/documents/revocation.py b/duniterpy/documents/revocation.py index 0f7d3fe91e42f0b426ba3353c6816c48e9185c68..4efeb4236fc1f54a6ac221dcb861a6c2e1ffea40 100644 --- a/duniterpy/documents/revocation.py +++ b/duniterpy/documents/revocation.py @@ -15,10 +15,10 @@ import base64 import re -from typing import Union, Type, TypeVar +from typing import Type, TypeVar, Union +from ..constants import BLOCK_UID_REGEX, PUBKEY_REGEX, SIGNATURE_REGEX from .block_uid import BlockUID -from ..constants import PUBKEY_REGEX, SIGNATURE_REGEX, BLOCK_UID_REGEX from .document import Document, MalformedDocumentError from .identity import Identity diff --git a/duniterpy/documents/transaction.py b/duniterpy/documents/transaction.py index 887b6d3c91930ccc0bd1731e7b0b8b0fa2f33708..21a4b3ebd566e0138530bcaf0d3a47375d21bfa7 100644 --- a/duniterpy/documents/transaction.py +++ b/duniterpy/documents/transaction.py @@ -14,20 +14,21 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. import re -from typing import TypeVar, List, Any, Type, Optional, Dict, Union, Tuple +from typing import Any, Dict, List, Optional, Tuple, Type, TypeVar, Union import pypeg2 from duniterpy.grammars.output import Condition -from .block_uid import BlockUID -from .document import Document, MalformedDocumentError + from ..constants import ( - PUBKEY_REGEX, - TRANSACTION_HASH_REGEX, BLOCK_ID_REGEX, BLOCK_UID_REGEX, + PUBKEY_REGEX, + TRANSACTION_HASH_REGEX, ) from ..grammars import output +from .block_uid import BlockUID +from .document import Document, MalformedDocumentError def reduce_base(amount: int, base: int) -> Tuple[int, int]: diff --git a/duniterpy/documents/ws2p/heads.py b/duniterpy/documents/ws2p/heads.py index 17404cc72a6e3dd362653b6e8a55d27a08ab3a85..a942b355649ff442ef45a73cf8077cb054edf05b 100644 --- a/duniterpy/documents/ws2p/heads.py +++ b/duniterpy/documents/ws2p/heads.py @@ -14,19 +14,20 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. import re + import attr -from ..block_uid import BlockUID -from ..document import MalformedDocumentError from ...constants import ( - WS2P_PUBLIC_PREFIX_REGEX, - WS2P_PRIVATE_PREFIX_REGEX, - WS2P_HEAD_REGEX, + BLOCK_UID_REGEX, PUBKEY_REGEX, SIGNATURE_REGEX, + WS2P_HEAD_REGEX, + WS2P_PRIVATE_PREFIX_REGEX, + WS2P_PUBLIC_PREFIX_REGEX, WS2PID_REGEX, - BLOCK_UID_REGEX, ) +from ..block_uid import BlockUID +from ..document import MalformedDocumentError @attr.s() diff --git a/duniterpy/documents/ws2p/messages.py b/duniterpy/documents/ws2p/messages.py index 02ab7069c3ea1548ba9ecfeea31b237bdc052d7d..a5f7a90419385d7dfcafb18fb612c27be75ec351 100644 --- a/duniterpy/documents/ws2p/messages.py +++ b/duniterpy/documents/ws2p/messages.py @@ -14,11 +14,10 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. import json - from typing import Optional from duniterpy.documents import Document -from duniterpy.key import VerifyingKey, SigningKey +from duniterpy.key import SigningKey, VerifyingKey from duniterpy.tools import get_ws2p_challenge diff --git a/duniterpy/grammars/output.py b/duniterpy/grammars/output.py index 9a0cb6fbf8b35492d8fa937336cb63b7a6023552..39642772a2a0a778899aa32ea3914066f46500b4 100644 --- a/duniterpy/grammars/output.py +++ b/duniterpy/grammars/output.py @@ -13,11 +13,11 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -from typing import Optional, TypeVar, Type, Any, Union +from typing import Any, Optional, Type, TypeVar, Union -from pypeg2 import re, attr, Keyword, Enum, contiguous, maybe_some, whitespace, K +from pypeg2 import Enum, K, Keyword, attr, contiguous, maybe_some, re, whitespace -from ..constants import PUBKEY_REGEX, HASH_REGEX +from ..constants import HASH_REGEX, PUBKEY_REGEX class Pubkey(str): diff --git a/duniterpy/helpers/blockchain.py b/duniterpy/helpers/blockchain.py index af6ea34bc6c5f1f0173db97f23f17bfe9ed8f89b..f6c8f8a8670dd61f1a0ff0949bf9902222d99509 100644 --- a/duniterpy/helpers/blockchain.py +++ b/duniterpy/helpers/blockchain.py @@ -44,6 +44,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. import json import pathlib + from ..documents import Block CHUNK_SIZE = 250 diff --git a/duniterpy/helpers/money.py b/duniterpy/helpers/money.py index 36f540627c0d7ff9e7b94559d02b0b11ad9a4214..7acf751a11a236476ad30ab29e96b11f83f04df6 100644 --- a/duniterpy/helpers/money.py +++ b/duniterpy/helpers/money.py @@ -13,8 +13,9 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -from typing import Union, Any -from duniterpy.grammars.output import SIG, CSV, CLTV, XHX, Condition +from typing import Any, Union + +from duniterpy.grammars.output import CLTV, CSV, SIG, XHX, Condition def output_available( diff --git a/duniterpy/helpers/network.py b/duniterpy/helpers/network.py index f136d8b6bf0b280cde7bf78d484f238bb61be905..430838a7c8bb5cd3d7a47dfe8ca0c857894dc7e5 100644 --- a/duniterpy/helpers/network.py +++ b/duniterpy/helpers/network.py @@ -13,14 +13,13 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -from typing import List, Dict, Any +from itertools import groupby +from typing import Any, Dict, List from duniterpy.api import bma from duniterpy.api.client import Client -from duniterpy.documents.peer import Peer, MalformedDocumentError +from duniterpy.documents.peer import MalformedDocumentError, Peer from duniterpy.documents.ws2p.heads import HeadV2 -from itertools import groupby - from duniterpy.key import VerifyingKey diff --git a/duniterpy/helpers/ws2p.py b/duniterpy/helpers/ws2p.py index 2efc656cbf10e63161d494bba1964603df1d0106..7aae54e3c5853189ba29d487db107ae734789cf7 100644 --- a/duniterpy/helpers/ws2p.py +++ b/duniterpy/helpers/ws2p.py @@ -13,14 +13,16 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -import jsonschema +import logging from typing import Union -from duniterpy.api import ws2p, bma -from duniterpy.api.client import WSConnection, Client + +import jsonschema + +from duniterpy.api import bma, ws2p +from duniterpy.api.client import Client, WSConnection from duniterpy.api.endpoint import BMAEndpoint, SecuredBMAEndpoint, WS2PEndpoint -from duniterpy.documents.ws2p.messages import Connect, Ack, Ok +from duniterpy.documents.ws2p.messages import Ack, Connect, Ok from duniterpy.key import SigningKey -import logging def handshake(ws: WSConnection, signing_key: SigningKey, currency: str): diff --git a/duniterpy/key/__init__.py b/duniterpy/key/__init__.py index 2966e76d850da611b8abcf76a8e04f7b1551c69a..59257a1945e96aff87954a76df1d2138c8779a11 100644 --- a/duniterpy/key/__init__.py +++ b/duniterpy/key/__init__.py @@ -13,7 +13,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +from .ascii_armor import AsciiArmor +from .encryption_key import PublicKey, SecretKey from .signing_key import SigningKey from .verifying_key import VerifyingKey -from .encryption_key import SecretKey, PublicKey -from .ascii_armor import AsciiArmor diff --git a/duniterpy/key/ascii_armor.py b/duniterpy/key/ascii_armor.py index 640ec981884f82cebaa13bfc9b984c58564aa4cd..e937687bfdf7376885ae065de84e4324dcb9bec4 100644 --- a/duniterpy/key/ascii_armor.py +++ b/duniterpy/key/ascii_armor.py @@ -14,12 +14,13 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. import base64 +import re +from typing import Any, Dict, List, Optional + import libnacl from libnacl.version import version as libnacl_version -import re -from typing import Optional, List, Dict, Any -from duniterpy.key import SigningKey, PublicKey, VerifyingKey +from duniterpy.key import PublicKey, SigningKey, VerifyingKey # Headers constants BEGIN_MESSAGE_HEADER = "-----BEGIN DUNITER MESSAGE-----" diff --git a/duniterpy/key/base58.py b/duniterpy/key/base58.py index 9a786d6e400682e603a2890705e3423329cd815a..8e3be555a32caf27b0a41643ac38b00d924bfe75 100644 --- a/duniterpy/key/base58.py +++ b/duniterpy/key/base58.py @@ -17,7 +17,7 @@ from typing import Union import base58 -from ..tools import ensure_str, ensure_bytes +from ..tools import ensure_bytes, ensure_str class Base58Encoder: diff --git a/duniterpy/key/encryption_key.py b/duniterpy/key/encryption_key.py index 7c155879666f77628c28bbb4f278258ed297b65f..c2abe1bff78d73b52a0d035fff5201a692cef733 100644 --- a/duniterpy/key/encryption_key.py +++ b/duniterpy/key/encryption_key.py @@ -13,14 +13,14 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -from typing import Union, Optional +from hashlib import scrypt +from typing import Optional, Union import libnacl.public -from hashlib import scrypt -from .scrypt_params import ScryptParams -from .base58 import Base58Encoder from ..tools import ensure_bytes +from .base58 import Base58Encoder +from .scrypt_params import ScryptParams class SecretKey(libnacl.public.SecretKey): diff --git a/duniterpy/key/signing_key.py b/duniterpy/key/signing_key.py index 6ec5adac06748a2ff2abdf2547e4c1b348574870..2600fce71265ec785e5112489743572049faa2d8 100644 --- a/duniterpy/key/signing_key.py +++ b/duniterpy/key/signing_key.py @@ -15,21 +15,21 @@ import base64 import re -from typing import Optional, Union, TypeVar, Type +from hashlib import scrypt, sha256 +from typing import Optional, Type, TypeVar, Union import libnacl.sign import pyaes from libnacl.utils import load_key -from hashlib import scrypt, sha256 -from .scrypt_params import ScryptParams -from .base58 import Base58Encoder from ..tools import ( + convert_seed_to_seedhex, + convert_seedhex_to_seed, ensure_bytes, xor_bytes, - convert_seedhex_to_seed, - convert_seed_to_seedhex, ) +from .base58 import Base58Encoder +from .scrypt_params import ScryptParams # required to type hint cls in classmethod SigningKeyType = TypeVar("SigningKeyType", bound="SigningKey") diff --git a/duniterpy/key/verifying_key.py b/duniterpy/key/verifying_key.py index fdc5cee3d0af03615c24b96ffe08b9e37425fff7..18e23b4d40b8cfdfd5bfafd337021c8e6dfead79 100644 --- a/duniterpy/key/verifying_key.py +++ b/duniterpy/key/verifying_key.py @@ -16,11 +16,12 @@ import base64 from typing import Any -import libnacl.sign import libnacl.encode +import libnacl.sign from duniterpy.documents import Document from duniterpy.documents.block import Block + from .base58 import Base58Encoder diff --git a/duniterpy/tools.py b/duniterpy/tools.py index c833cc141af461d5927812edf07230f24306af26..711b42ac32088d33f17c1b8e445585c23995a6ca 100644 --- a/duniterpy/tools.py +++ b/duniterpy/tools.py @@ -15,6 +15,7 @@ import uuid from typing import Union + from libnacl.encode import hex_decode, hex_encode diff --git a/examples/create_public_key.py b/examples/create_public_key.py index c95ff9e2f8333f068b0a4626829eaaa2f4902987..8b1fee8923c27aca1fdd37af1f482671f0eb0139 100644 --- a/examples/create_public_key.py +++ b/examples/create_public_key.py @@ -14,6 +14,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. import getpass + from duniterpy.key import SigningKey ################################################ diff --git a/examples/listen_ws2p.py b/examples/listen_ws2p.py index a74c588e5e276f8c3492cff13e877037beabab1d..e0e56098fb3ef3d0c57589601db1c71ba58d60e4 100644 --- a/examples/listen_ws2p.py +++ b/examples/listen_ws2p.py @@ -14,11 +14,12 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. import json + import jsonschema -from duniterpy.key import SigningKey -from duniterpy.helpers.ws2p import handshake, generate_ws2p_endpoint from duniterpy.api.client import Client +from duniterpy.helpers.ws2p import generate_ws2p_endpoint, handshake +from duniterpy.key import SigningKey # CONFIG ####################################### diff --git a/examples/request_available_nodes.py b/examples/request_available_nodes.py index 91b580387d02c5d0bdb057ba784b0ccfd4d8eed4..958d81010595a928df41e1e1811f33ecc0dc07cc 100644 --- a/examples/request_available_nodes.py +++ b/examples/request_available_nodes.py @@ -13,8 +13,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -from duniterpy.helpers import network from duniterpy.api.client import Client +from duniterpy.helpers import network # CONFIG ####################################### diff --git a/examples/request_data.py b/examples/request_data.py index 62b892ff5e7c49b747ea120fd0be74ee62ff5c52..a35f101abe47a80cbd45031d29c7bdc79461ad5f 100644 --- a/examples/request_data.py +++ b/examples/request_data.py @@ -13,8 +13,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -from duniterpy.api.client import Client, RESPONSE_HTTP from duniterpy.api import bma +from duniterpy.api.client import RESPONSE_HTTP, Client # CONFIG ####################################### diff --git a/examples/request_data_graphql.py b/examples/request_data_graphql.py index 0d2ec371f2be9dcc8dcc4603e4091b3f196e1586..f9ca8e066a97cc90ab2a511156b699442cf4f171 100644 --- a/examples/request_data_graphql.py +++ b/examples/request_data_graphql.py @@ -15,10 +15,11 @@ import json -from duniterpy.api.client import Client -from graphql import get_introspection_query, build_client_schema, language, validate +from graphql import build_client_schema, get_introspection_query, language, validate from graphql.error import GraphQLSyntaxError +from duniterpy.api.client import Client + # CONFIG ####################################### # You can either use a complete defined endpoint : [NAME_OF_THE_API] [DOMAIN] [IPv4] [IPv6] [PORT] diff --git a/examples/request_ws2p.py b/examples/request_ws2p.py index f7a3191cf8838d5916daaa88c1edffbbac092022..0da0eb231c228e0bd8446307c14bcb21dbb49acc 100644 --- a/examples/request_ws2p.py +++ b/examples/request_ws2p.py @@ -15,17 +15,16 @@ import json import time +from typing import Any import jsonschema from jsonschema import ValidationError -from typing import Any - -from duniterpy.tools import get_ws2p_challenge -from duniterpy.key import SigningKey -from duniterpy.helpers.ws2p import handshake, generate_ws2p_endpoint -from duniterpy.api.ws2p import requests from duniterpy.api.client import Client, WSConnection +from duniterpy.api.ws2p import requests +from duniterpy.helpers.ws2p import generate_ws2p_endpoint, handshake +from duniterpy.key import SigningKey +from duniterpy.tools import get_ws2p_challenge # CONFIG ####################################### diff --git a/examples/save_and_load_private_key_file.py b/examples/save_and_load_private_key_file.py index 41f06abd56548e48e61836b58919d1bbcbfa1595..95adb9f06bc72be03e2eadee4ef30c57442ea5e0 100644 --- a/examples/save_and_load_private_key_file.py +++ b/examples/save_and_load_private_key_file.py @@ -13,10 +13,11 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -from duniterpy.key import SigningKey import getpass import os +from duniterpy.key import SigningKey + if "XDG_CONFIG_HOME" in os.environ: home_path = os.environ["XDG_CONFIG_HOME"] elif "HOME" in os.environ: diff --git a/examples/save_and_load_private_key_file_ewif.py b/examples/save_and_load_private_key_file_ewif.py index ad1a1a9dee4414bc13779bcdc8ba07a7dd53192e..07e23157c05f2d679143e16307bdc4ffc7fdea9c 100644 --- a/examples/save_and_load_private_key_file_ewif.py +++ b/examples/save_and_load_private_key_file_ewif.py @@ -13,10 +13,11 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -from duniterpy.key import SigningKey import getpass import os +from duniterpy.key import SigningKey + if "XDG_CONFIG_HOME" in os.environ: home_path = os.environ["XDG_CONFIG_HOME"] elif "HOME" in os.environ: diff --git a/examples/save_and_load_private_key_file_pubsec.py b/examples/save_and_load_private_key_file_pubsec.py index fa19a076bedbcfc1c1d822edb6767206c59ed44c..701f235ea9b715f5a634b6b16dbf96df16b6c608 100644 --- a/examples/save_and_load_private_key_file_pubsec.py +++ b/examples/save_and_load_private_key_file_pubsec.py @@ -13,10 +13,11 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -from duniterpy.key import SigningKey import getpass import os +from duniterpy.key import SigningKey + if "XDG_CONFIG_HOME" in os.environ: home_path = os.environ["XDG_CONFIG_HOME"] elif "HOME" in os.environ: diff --git a/examples/save_and_load_private_key_file_wif.py b/examples/save_and_load_private_key_file_wif.py index 033b63aa96755dd52c38b36cc96947d2fba548c2..78c218c0172ef0601ec4b43bacad3cad9a5f8068 100644 --- a/examples/save_and_load_private_key_file_wif.py +++ b/examples/save_and_load_private_key_file_wif.py @@ -13,10 +13,11 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -from duniterpy.key import SigningKey import getpass import os +from duniterpy.key import SigningKey + if "XDG_CONFIG_HOME" in os.environ: home_path = os.environ["XDG_CONFIG_HOME"] elif "HOME" in os.environ: diff --git a/examples/save_cleartext_ascii_armor_message.py b/examples/save_cleartext_ascii_armor_message.py index 297a8bdc626ee510d21c11e663a3c7da2f9f079b..00f68ec65382a57a3dd4fbda4a856cb44da92b39 100644 --- a/examples/save_cleartext_ascii_armor_message.py +++ b/examples/save_cleartext_ascii_armor_message.py @@ -17,7 +17,6 @@ import getpass import sys from duniterpy import __version__ - from duniterpy.key import AsciiArmor, SigningKey # CONFIG ####################################### diff --git a/examples/save_encrypted_ascii_armor_message.py b/examples/save_encrypted_ascii_armor_message.py index 4cd488ffbd3979b37252a524cb934e7305704326..c464b019e094571db3b92ab259962488f797b1d2 100644 --- a/examples/save_encrypted_ascii_armor_message.py +++ b/examples/save_encrypted_ascii_armor_message.py @@ -14,8 +14,8 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. import getpass -from duniterpy import __version__ +from duniterpy import __version__ from duniterpy.key import AsciiArmor, SigningKey # CONFIG ####################################### diff --git a/examples/save_revoke_document.py b/examples/save_revoke_document.py index ec76326a4498b2601ccb667946697ca05830b9b9..8f1ba26afdc83e691c5cda8d3e44285751717bd3 100644 --- a/examples/save_revoke_document.py +++ b/examples/save_revoke_document.py @@ -19,7 +19,7 @@ from typing import Optional from duniterpy.api import bma from duniterpy.api.client import Client -from duniterpy.documents import Revocation, BlockUID, Identity +from duniterpy.documents import BlockUID, Identity, Revocation from duniterpy.key import SigningKey if "XDG_CONFIG_HOME" in os.environ: diff --git a/examples/send_certification.py b/examples/send_certification.py index e1e5adfbe1f1e71b2724fa64ad5876d48c517ace..b9bc7c0f832284acc5e561ad43dcae6f8fbaa10a 100644 --- a/examples/send_certification.py +++ b/examples/send_certification.py @@ -14,12 +14,12 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. import getpass -from typing import Optional import urllib +from typing import Optional from duniterpy.api import bma from duniterpy.api.client import Client -from duniterpy.documents import BlockUID, Identity, Certification +from duniterpy.documents import BlockUID, Certification, Identity from duniterpy.key import SigningKey # CONFIG ####################################### diff --git a/examples/send_transaction.py b/examples/send_transaction.py index 88d315620ae771914efc9776e278cbda770b5cd1..77462fe7f0aea02fe25c5036783ce2c206b4c196 100644 --- a/examples/send_transaction.py +++ b/examples/send_transaction.py @@ -22,8 +22,8 @@ from duniterpy.documents import BlockUID, Transaction from duniterpy.documents.transaction import ( InputSource, OutputSource, - Unlock, SIGParameter, + Unlock, ) from duniterpy.key import SigningKey diff --git a/tests/api/bma/test_bma.py b/tests/api/bma/test_bma.py index e56e79d3e4f7fb7847207d3c216066063004e7b2..06417780bc506f7efad6a0a91dccb2fcf5418250 100644 --- a/tests/api/bma/test_bma.py +++ b/tests/api/bma/test_bma.py @@ -16,7 +16,7 @@ import unittest from duniterpy.api.client import API, parse_error -from duniterpy.api.endpoint import BMAEndpoint, SecuredBMAEndpoint, GVAEndpoint +from duniterpy.api.endpoint import BMAEndpoint, GVAEndpoint, SecuredBMAEndpoint class TestBmaApi(unittest.TestCase): diff --git a/tests/api/bma/test_network.py b/tests/api/bma/test_network.py index a83f9a8d3fa5cedebd5697c984b7b0ab92a5849f..84892fb6e57c7fdec031f12dd3fb11d4fad21101 100644 --- a/tests/api/bma/test_network.py +++ b/tests/api/bma/test_network.py @@ -16,7 +16,7 @@ import unittest import jsonschema -from jsonschema import ValidationError, SchemaError +from jsonschema import SchemaError, ValidationError from duniterpy.api.bma import network diff --git a/tests/api/bma/test_tx.py b/tests/api/bma/test_tx.py index c3ca16fa3963c7197e8a8a71f8fc3dd29bf2bf54..211787cf2bf0ef6ce05d84de3ae947130c963c79 100644 --- a/tests/api/bma/test_tx.py +++ b/tests/api/bma/test_tx.py @@ -18,10 +18,7 @@ import unittest import jsonschema from jsonschema import SchemaError, ValidationError -from duniterpy.api.bma.tx import ( - HISTORY_SCHEMA, - SOURCES_SCHEMA, -) +from duniterpy.api.bma.tx import HISTORY_SCHEMA, SOURCES_SCHEMA class TestBmaTx(unittest.TestCase): diff --git a/tests/api/bma/test_wot.py b/tests/api/bma/test_wot.py index 3b522ca6243bab57a47b8af786bcedaa42fa311f..029ffdab68fc56b4ae9f93ce737280ae5eb1f40a 100644 --- a/tests/api/bma/test_wot.py +++ b/tests/api/bma/test_wot.py @@ -19,10 +19,10 @@ import jsonschema from jsonschema import SchemaError, ValidationError from duniterpy.api.bma.wot import ( - REQUIREMENTS_SCHEMA, CERTIFICATIONS_SCHEMA, LOOKUP_SCHEMA, MEMBERS_SCHEMA, + REQUIREMENTS_SCHEMA, ) diff --git a/tests/api/ws2p/test_ws2p.py b/tests/api/ws2p/test_ws2p.py index 11a619acdd4f8c7447c1a8f964d556f4d57944c2..2a5e3c1231edc2d9fb95ddb726570bc3c3d48999 100644 --- a/tests/api/ws2p/test_ws2p.py +++ b/tests/api/ws2p/test_ws2p.py @@ -18,15 +18,15 @@ import unittest import jsonschema -from duniterpy.api.client import parse_text from duniterpy.api.bma.network import WS2P_HEADS_SCHEMA +from duniterpy.api.client import parse_text from duniterpy.api.ws2p.requests import ( BLOCK_RESPONSE_SCHEMA, - ERROR_RESPONSE_SCHEMA, BLOCKS_RESPONSE_SCHEMA, + ERROR_RESPONSE_SCHEMA, REQUIREMENTS_RESPONSE_SCHEMA, ) -from duniterpy.documents import Identity, BlockUID +from duniterpy.documents import BlockUID, Identity from duniterpy.documents.ws2p.messages import DocumentMessage diff --git a/tests/documents/test_block.py b/tests/documents/test_block.py index a6db811112fd834cb19aab487b8e8f7e6eb444b4..dfcf032e9b339bdf8acc351bec5529c588bfb632 100644 --- a/tests/documents/test_block.py +++ b/tests/documents/test_block.py @@ -13,8 +13,8 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -import unittest import json +import unittest from duniterpy.documents.block import Block from duniterpy.documents.block_uid import BlockUID, block_uid diff --git a/tests/documents/test_certification.py b/tests/documents/test_certification.py index 17b7b30c18a107c82a6339f76a30890a8d0e4ff7..510f832a98cc522500dd67c89c30940c4b711a06 100644 --- a/tests/documents/test_certification.py +++ b/tests/documents/test_certification.py @@ -14,11 +14,12 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. import unittest + +from duniterpy.constants import EMPTY_HASH +from duniterpy.documents.block import BlockUID from duniterpy.documents.certification import Certification -from duniterpy.documents.revocation import Revocation from duniterpy.documents.identity import Identity -from duniterpy.documents.block import BlockUID -from duniterpy.constants import EMPTY_HASH +from duniterpy.documents.revocation import Revocation selfcert_inlines = [ "HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk:\ diff --git a/tests/documents/test_crc_pubkey.py b/tests/documents/test_crc_pubkey.py index 89f50103374aed99fd3598cd76eadb195a66d48d..638672f31ae3297eed79479b01d93eef08f66d69 100644 --- a/tests/documents/test_crc_pubkey.py +++ b/tests/documents/test_crc_pubkey.py @@ -14,6 +14,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. import unittest + from duniterpy.documents.crc_pubkey import CRCPubkey diff --git a/tests/documents/test_membership.py b/tests/documents/test_membership.py index 82a0f4df230bbfd5937c8d10894a3c88748d4601..8d9919bbaf63231e30b2befb6bb2457703f6268d 100644 --- a/tests/documents/test_membership.py +++ b/tests/documents/test_membership.py @@ -14,6 +14,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. import unittest + from duniterpy.documents.membership import Membership membership_inline = "HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk:\ diff --git a/tests/documents/test_transaction.py b/tests/documents/test_transaction.py index 36ef36e2c4f5e71e8b16551f86129fc91b34e25a..6f0a598c786a9182b1efe3c6bc75eade3604f35c 100644 --- a/tests/documents/test_transaction.py +++ b/tests/documents/test_transaction.py @@ -14,18 +14,20 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. import unittest + import pypeg2 -from duniterpy.grammars import output + from duniterpy.documents import BlockUID from duniterpy.documents.transaction import ( - Transaction, - reduce_base, - SimpleTransaction, InputSource, OutputSource, - Unlock, SIGParameter, + SimpleTransaction, + Transaction, + Unlock, + reduce_base, ) +from duniterpy.grammars import output compact_change = """TX:10:1:1:1:1:1:0 13410-000041DF0CCA173F09B5FBA48F619D4BC934F12ADF1D0B798639EB2149C4A8CC diff --git a/tests/documents/test_ws2p_heads.py b/tests/documents/test_ws2p_heads.py index 3013adc12749af86b21327b0368226205bb52435..8b79ac1575da5f7238c8cacfaec5efff39b5f40d 100644 --- a/tests/documents/test_ws2p_heads.py +++ b/tests/documents/test_ws2p_heads.py @@ -15,7 +15,7 @@ import unittest -from duniterpy.documents.ws2p.heads import HeadV0, HeadV1, HeadV2, BlockUID +from duniterpy.documents.ws2p.heads import BlockUID, HeadV0, HeadV1, HeadV2 headv1_clear = "" diff --git a/tests/grammars/test_output.py b/tests/grammars/test_output.py index fc8e33f3689af72b5a60d577874cb725ad259faf..9655e9fc53e355a25eb4b0dce87df5a3dba608e8 100644 --- a/tests/grammars/test_output.py +++ b/tests/grammars/test_output.py @@ -17,7 +17,7 @@ import unittest import pypeg2 -from duniterpy.grammars.output import SIG, CLTV, CSV, XHX, Operator, Condition +from duniterpy.grammars.output import CLTV, CSV, SIG, XHX, Condition, Operator pubkey = "DNann1Lh55eZMEDXeYt59bzHbA3NJR46DeQYCS2qQdLV" diff --git a/tests/helpers/money.py b/tests/helpers/money.py index d32d4b73c78884011351c59bdf002f6112bb6aac..131cc12d05f8b4ca4bf6be772dcfa0b01e23ab26 100644 --- a/tests/helpers/money.py +++ b/tests/helpers/money.py @@ -14,10 +14,11 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. import unittest -from operator import eq, ne, lt, ge -from duniterpy.helpers.money import output_available -from duniterpy.grammars.output import SIG, XHX, CLTV, CSV +from operator import eq, ge, lt, ne + from duniterpy.documents.transaction import OutputSource +from duniterpy.grammars.output import CLTV, CSV, SIG, XHX +from duniterpy.helpers.money import output_available class TestHelpersMoney(unittest.TestCase): diff --git a/tests/helpers/ws2p.py b/tests/helpers/ws2p.py index abe13492207146e91196254f0d72a2dcacb5dc10..8ad4a1ba64f81d489fe9449cf8aa2fcd12cd46fe 100644 --- a/tests/helpers/ws2p.py +++ b/tests/helpers/ws2p.py @@ -15,8 +15,8 @@ import pytest +from duniterpy.api.endpoint import BMAEndpoint, SecuredBMAEndpoint, WS2PEndpoint from duniterpy.helpers.ws2p import generate_ws2p_endpoint -from duniterpy.api.endpoint import WS2PEndpoint, SecuredBMAEndpoint, BMAEndpoint def peering_no_ws2p(self): diff --git a/tests/key/test_ascii_armor.py b/tests/key/test_ascii_armor.py index d3c6bf7d1032d141d76559fb4ad07d82ab13be54..ff74ef7f0b88cd8e4755728c94c4ad0f6022447b 100644 --- a/tests/key/test_ascii_armor.py +++ b/tests/key/test_ascii_armor.py @@ -13,14 +13,15 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +import unittest + from duniterpy.key import AsciiArmor, SigningKey from duniterpy.key.ascii_armor import ( BEGIN_MESSAGE_HEADER, BEGIN_SIGNATURE_HEADER, - END_SIGNATURE_HEADER, END_MESSAGE_HEADER, + END_SIGNATURE_HEADER, ) -import unittest class TestAsciiArmor(unittest.TestCase): diff --git a/tests/key/test_encryption_key.py b/tests/key/test_encryption_key.py index 7db774c7a9220dedd840f62aedeaa8eea59cbb70..777cac61f58646be5afd8076de8874be47203cfa 100644 --- a/tests/key/test_encryption_key.py +++ b/tests/key/test_encryption_key.py @@ -13,9 +13,10 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -from duniterpy.key import SecretKey import unittest +from duniterpy.key import SecretKey + class TestEncryptionKey(unittest.TestCase): def test_from_bob_to_alice(self): diff --git a/tests/key/test_public_key.py b/tests/key/test_public_key.py index 89096f22c91b65e2a8eb409194e3e25866a753df..ffa451f9ea1079055b74d8b3dea1331b890e4784 100644 --- a/tests/key/test_public_key.py +++ b/tests/key/test_public_key.py @@ -13,10 +13,11 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -from duniterpy.key import SigningKey, PublicKey -from duniterpy.key.scrypt_params import ScryptParams import unittest +from duniterpy.key import PublicKey, SigningKey +from duniterpy.key.scrypt_params import ScryptParams + class TestPublicKey(unittest.TestCase): def test_encrypt_seal(self): diff --git a/tests/key/test_signing_key.py b/tests/key/test_signing_key.py index 5b88f1792eb15549fdf497c8fd3b0e4b16f61857..16aed9d03f317e53c450cbc6d82b5274503f6c0f 100644 --- a/tests/key/test_signing_key.py +++ b/tests/key/test_signing_key.py @@ -15,10 +15,10 @@ import base64 import os +import unittest -from duniterpy.key import VerifyingKey, SigningKey, PublicKey +from duniterpy.key import PublicKey, SigningKey, VerifyingKey from duniterpy.key.scrypt_params import ScryptParams -import unittest TEST_FILE_PATH = "/tmp/test_file.txt" diff --git a/tests/key/test_verifying_key.py b/tests/key/test_verifying_key.py index 64cfceb53d5f695fee9d2575297ca3f4a16bdc5b..36684635eba4865f3b9f1570d543cb8b8d478a59 100644 --- a/tests/key/test_verifying_key.py +++ b/tests/key/test_verifying_key.py @@ -13,13 +13,14 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -from duniterpy.key import VerifyingKey, SigningKey -from duniterpy.key.scrypt_params import ScryptParams -from duniterpy.documents.peer import Peer -from duniterpy.documents.ws2p.heads import HeadV0, HeadV1, HeadV2 +import unittest + from duniterpy.documents import Block +from duniterpy.documents.peer import Peer from duniterpy.documents.transaction import Transaction -import unittest +from duniterpy.documents.ws2p.heads import HeadV0, HeadV1, HeadV2 +from duniterpy.key import SigningKey, VerifyingKey +from duniterpy.key.scrypt_params import ScryptParams class TestVerifyingKey(unittest.TestCase):