diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 5bb976da2c4deccf986784eddc900b21fce2cab9..fa1254d02cff828bef85366164bc3cd34b2c0795 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,18 +10,18 @@ repos: - id: isort args: ["--profile", "black"] - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.982 + rev: v0.991 hooks: - id: mypy args: - "--install-types" - "--non-interactive" - repo: https://github.com/PyCQA/pylint - rev: v2.15.4 + rev: v2.15.8 hooks: - id: pylint - repo: https://github.com/asottile/pyupgrade - rev: v3.1.0 + rev: v3.3.1 hooks: - id: pyupgrade args: [--py37-plus] diff --git a/duniterpy/api/bma/blockchain.py b/duniterpy/api/bma/blockchain.py index 1849bd0420f9411aae8d1bc6db9b4a50e28dcc64..8110cc67c2495853aec331154fb95449993d9fd9 100644 --- a/duniterpy/api/bma/blockchain.py +++ b/duniterpy/api/bma/blockchain.py @@ -15,7 +15,7 @@ import logging from http.client import HTTPResponse -from typing import Union +from typing import Optional, Union from duniterpy.api.client import RESPONSE_HTTP, Client @@ -266,7 +266,10 @@ def current(client: Client) -> dict: def block( - client: Client, number: int = 0, block_raw: str = None, signature: str = None + client: Client, + number: int = 0, + block_raw: Optional[str] = None, + signature: Optional[str] = None, ) -> Union[dict, HTTPResponse]: """ GET/POST a block from/to the blockchain diff --git a/duniterpy/api/endpoint.py b/duniterpy/api/endpoint.py index 89596fdaabffd32e5771aa7bdcc87774a84d55c7..829c44222268482ae3a2f9571661c22da4375117 100644 --- a/duniterpy/api/endpoint.py +++ b/duniterpy/api/endpoint.py @@ -67,7 +67,7 @@ class Endpoint: def inline(self) -> str: raise NotImplementedError("inline() is not implemented") - def conn_handler(self, proxy: str = None) -> ConnectionHandler: + def conn_handler(self, proxy: Optional[str] = None) -> ConnectionHandler: raise NotImplementedError("conn_handler is not implemented") def __str__(self) -> str: @@ -114,7 +114,7 @@ class UnknownEndpoint(Endpoint): doc += f" {p}" return doc - def conn_handler(self, proxy: str = None) -> ConnectionHandler: + def conn_handler(self, proxy: Optional[str] = None) -> ConnectionHandler: """ Return connection handler @@ -188,7 +188,7 @@ class BMAEndpoint(Endpoint): ] return f'{self.API} {" ".join(inlined)}' - def conn_handler(self, proxy: str = None) -> ConnectionHandler: + def conn_handler(self, proxy: Optional[str] = None) -> ConnectionHandler: """ Return connection handler instance for the endpoint @@ -285,7 +285,7 @@ class SecuredBMAEndpoint(BMAEndpoint): ] return f'{self.API} {" ".join(inlined)}' - def conn_handler(self, proxy: str = None) -> ConnectionHandler: + def conn_handler(self, proxy: Optional[str] = None) -> ConnectionHandler: """ Return connection handler instance for the endpoint @@ -354,7 +354,7 @@ class WS2PEndpoint(Endpoint): ] return f'{self.API} {" ".join(inlined)}' - def conn_handler(self, proxy: str = None) -> ConnectionHandler: + def conn_handler(self, proxy: Optional[str] = None) -> ConnectionHandler: """ Return connection handler instance for the endpoint @@ -425,7 +425,7 @@ class ESCoreEndpoint(Endpoint): inlined = [str(info) for info in (self.host, self.port) if info] return f'{self.API} {" ".join(inlined)}' - def conn_handler(self, proxy: str = None) -> ConnectionHandler: + def conn_handler(self, proxy: Optional[str] = None) -> ConnectionHandler: """ Return connection handler instance for the endpoint @@ -484,7 +484,7 @@ class ESUserEndpoint(Endpoint): inlined = [str(info) for info in (self.host, self.port) if info] return f'{self.API} {" ".join(inlined)}' - def conn_handler(self, proxy: str = None) -> ConnectionHandler: + def conn_handler(self, proxy: Optional[str] = None) -> ConnectionHandler: """ Return connection handler instance for the endpoint @@ -547,7 +547,7 @@ class ESSubscribtionEndpoint(Endpoint): inlined = [str(info) for info in (self.host, self.port) if info] return f'{self.API} {" ".join(inlined)}' - def conn_handler(self, proxy: str = None) -> ConnectionHandler: + def conn_handler(self, proxy: Optional[str] = None) -> ConnectionHandler: """ Return connection handler instance for the endpoint @@ -646,7 +646,7 @@ class GVAEndpoint(Endpoint): ] return f'{self.API} {" ".join(inlined)}' - def conn_handler(self, proxy: str = None) -> ConnectionHandler: + def conn_handler(self, proxy: Optional[str] = None) -> ConnectionHandler: """ Return connection handler instance for the endpoint diff --git a/duniterpy/documents/block.py b/duniterpy/documents/block.py index a5d4d195d2e5b8d8784a8d4bd3c9a92013bafd72..3580159962dcfd0309effac90340e2d893ebc079 100644 --- a/duniterpy/documents/block.py +++ b/duniterpy/documents/block.py @@ -168,7 +168,7 @@ class Block(Document): transactions: List[Transaction], inner_hash: str, nonce: int, - signing_key: SigningKey = None, + signing_key: Optional[SigningKey] = None, version: int = VERSION, currency: str = G1_CURRENCY_CODENAME, ) -> None: diff --git a/duniterpy/documents/certification.py b/duniterpy/documents/certification.py index c268b9a947db89f0939658505e1cfd748e6bf5ad..8aa4fd828640f87987d4545d8909899848248180 100644 --- a/duniterpy/documents/certification.py +++ b/duniterpy/documents/certification.py @@ -57,7 +57,7 @@ class Certification(Document): pubkey_from: str, identity: Union[Identity, str], block_id: BlockID, - signing_key: SigningKey = None, + signing_key: Optional[SigningKey] = None, version: int = VERSION, currency: str = G1_CURRENCY_CODENAME, ) -> None: diff --git a/duniterpy/documents/identity.py b/duniterpy/documents/identity.py index dda8f37e53ff15420839f63959c0f44bcbd15131..1437320c44a7618e7d1756ab4f428239242cf2a8 100644 --- a/duniterpy/documents/identity.py +++ b/duniterpy/documents/identity.py @@ -14,7 +14,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. import re -from typing import Any, Type, TypeVar +from typing import Any, Optional, Type, TypeVar from ..constants import ( BLOCK_ID_REGEX, @@ -73,7 +73,7 @@ class Identity(Document): pubkey: str, uid: str, block_id: BlockID, - signing_key: SigningKey = None, + signing_key: Optional[SigningKey] = None, version: int = VERSION, currency: str = G1_CURRENCY_CODENAME, ) -> None: diff --git a/duniterpy/documents/membership.py b/duniterpy/documents/membership.py index 3ce7a407e28c4694359b7160455b08b60b4c045b..4ff7ac996fe6ac6875aa534c4b5bc845417bf6a8 100644 --- a/duniterpy/documents/membership.py +++ b/duniterpy/documents/membership.py @@ -14,7 +14,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. import re -from typing import Any, Type, TypeVar +from typing import Any, Optional, Type, TypeVar from ..constants import ( BLOCK_ID_REGEX, @@ -77,7 +77,7 @@ class Membership(Document): membership_block_id: BlockID, uid: str, identity_block_id: BlockID, - signing_key: SigningKey = None, + signing_key: Optional[SigningKey] = None, version: int = VERSION, currency: str = G1_CURRENCY_CODENAME, membership_type: str = "IN", diff --git a/duniterpy/documents/peer.py b/duniterpy/documents/peer.py index cfe5beece5069f1231b252c87120215632d5a7bf..408549188ebd65acfb119fdae73b036bba17b415 100644 --- a/duniterpy/documents/peer.py +++ b/duniterpy/documents/peer.py @@ -14,7 +14,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. import re -from typing import List, Type, TypeVar +from typing import List, Optional, Type, TypeVar from duniterpy.api.endpoint import Endpoint, endpoint @@ -67,7 +67,7 @@ class Peer(Document): pubkey: str, block_id: BlockID, endpoints: List[Endpoint], - signing_key: SigningKey = None, + signing_key: Optional[SigningKey] = None, version: int = VERSION, currency: str = G1_CURRENCY_CODENAME, ) -> None: diff --git a/duniterpy/documents/revocation.py b/duniterpy/documents/revocation.py index 528ca2d8e9b0bed63bca8be7f5900b9f7ee9a8b6..b30bfa1b27d5b2cf15cf0e667eda2d0722afdd33 100644 --- a/duniterpy/documents/revocation.py +++ b/duniterpy/documents/revocation.py @@ -14,7 +14,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. import re -from typing import Any, Type, TypeVar, Union +from typing import Any, Optional, Type, TypeVar, Union from ..constants import ( BLOCK_ID_REGEX, @@ -59,7 +59,7 @@ class Revocation(Document): def __init__( self, identity: Union[Identity, str], - signing_key: SigningKey = None, + signing_key: Optional[SigningKey] = None, version: int = VERSION, currency: str = G1_CURRENCY_CODENAME, ) -> None: diff --git a/duniterpy/grammars/output.py b/duniterpy/grammars/output.py index f9e0ef5055be94ce1f91221a18941e9ff941b853..a87d482708554b16bc435a7069055241343ea5b0 100644 --- a/duniterpy/grammars/output.py +++ b/duniterpy/grammars/output.py @@ -151,7 +151,7 @@ class CSV: return csv def compose( - self, parser: Any = None, grammar: Any = None, attr_of: str = None + self, parser: Any = None, grammar: Any = None, attr_of: Optional[str] = None ) -> str: """ Return the CSV(time) expression as string format @@ -210,7 +210,7 @@ class CLTV: return cltv def compose( - self, parser: Any = None, grammar: Any = None, attr_of: str = None + self, parser: Any = None, grammar: Any = None, attr_of: Optional[str] = None ) -> str: """ Return the CLTV(timestamp) expression as string format @@ -269,7 +269,7 @@ class XHX: return xhx def compose( - self, parser: Any = None, grammar: Any = None, attr_of: str = None + self, parser: Any = None, grammar: Any = None, attr_of: Optional[str] = None ) -> str: """ Return the XHX(sha_hash) expression as string format @@ -305,7 +305,7 @@ class Operator(Keyword): return op def compose( - self, parser: Any = None, grammar: Any = None, attr_of: str = None + self, parser: Any = None, grammar: Any = None, attr_of: Optional[str] = None ) -> str: """ Return the Operator keyword as string format @@ -382,7 +382,9 @@ class Condition: condition.right = right return condition - def compose(self, parser: Any, grammar: Any = None, attr_of: str = None) -> str: + def compose( + self, parser: Any, grammar: Any = None, attr_of: Optional[str] = None + ) -> str: """ Return the Condition as string format diff --git a/duniterpy/key/signing_key.py b/duniterpy/key/signing_key.py index 08d08007b1ba41c10ad1978822a8655301d2575c..53e2fe8a454adf7b941a6e03a4916a0aebbbf17b 100644 --- a/duniterpy/key/signing_key.py +++ b/duniterpy/key/signing_key.py @@ -500,7 +500,9 @@ Data: {ewif_key}" @classmethod def from_dubp_mnemonic( - cls: Type[SigningKeyType], mnemonic: str, scrypt_params: ScryptParams = None + cls: Type[SigningKeyType], + mnemonic: str, + scrypt_params: Optional[ScryptParams] = None, ) -> SigningKeyType: """ Generate key pair instance from a DUBP mnemonic passphrase