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

Support mypy v0.990 new Optional report

PEP 484 prohibits implicit Optional
Bump pre-commit hooks
parent c82238cb
No related branches found
No related tags found
1 merge request!178Support mypy v0.990 new Optional report
Pipeline #31797 waiting for manual action
......@@ -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]
......
......@@ -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
......
......@@ -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
......
......@@ -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:
......
......@@ -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:
......
......@@ -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:
......
......@@ -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",
......
......@@ -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:
......
......@@ -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:
......
......@@ -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
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment