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

Bump Mypy to v1.3.0 and fix new reports

Add call-arg exception to errors
https://mypy.readthedocs.io/en/stable/error_code_list.html#check-arguments-in-calls-call-arg
Not sure about attr.s() though

Fix notes
parent d4a032c4
Branches
Tags
1 merge request!182Bump rte, test, hooks, doc dependencies
Pipeline #32108 waiting for manual action
...@@ -10,7 +10,7 @@ repos: ...@@ -10,7 +10,7 @@ repos:
- id: isort - id: isort
args: ["--profile", "black"] args: ["--profile", "black"]
- repo: https://github.com/pre-commit/mirrors-mypy - repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.991 rev: v1.3.0
hooks: hooks:
- id: mypy - id: mypy
args: args:
......
...@@ -48,7 +48,7 @@ class API: ...@@ -48,7 +48,7 @@ class API:
raise MalformedDocumentError("WS2P API Document") raise MalformedDocumentError("WS2P API Document")
private = "" if data.group(1) is None else data.group(1) private = "" if data.group(1) is None else data.group(1)
public = "" if data.group(2) is None else data.group(2) public = "" if data.group(2) is None else data.group(2)
return cls(private, public) return cls(private, public) # type: ignore[call-arg]
def __str__(self) -> str: def __str__(self) -> str:
return f"WS2P{self.private}{self.public}" return f"WS2P{self.private}{self.public}"
...@@ -68,7 +68,7 @@ class Head: ...@@ -68,7 +68,7 @@ class Head:
raise MalformedDocumentError("Head") raise MalformedDocumentError("Head")
head = data.group(0).split(":") head = data.group(0).split(":")
version = int(head[1]) if len(head) == 2 else 0 version = int(head[1]) if len(head) == 2 else 0
return cls(version) return cls(version) # type: ignore[call-arg]
except AttributeError: except AttributeError:
raise MalformedDocumentError("Head") from AttributeError raise MalformedDocumentError("Head") from AttributeError
...@@ -102,7 +102,7 @@ class HeadV0(Head): ...@@ -102,7 +102,7 @@ class HeadV0(Head):
pubkey = data.group(3) pubkey = data.group(3)
block_id = BlockID.from_str(data.group(4)) block_id = BlockID.from_str(data.group(4))
offload = data.group(5) offload = data.group(5)
return cls(head.version, signature, api, head, pubkey, block_id), offload return cls(head.version, signature, api, head, pubkey, block_id), offload # type: ignore[call-arg]
except AttributeError: except AttributeError:
raise MalformedDocumentError("HeadV0") from AttributeError raise MalformedDocumentError("HeadV0") from AttributeError
...@@ -162,7 +162,7 @@ class HeadV1(HeadV0): ...@@ -162,7 +162,7 @@ class HeadV1(HeadV0):
pow_prefix = int(data.group(4)) pow_prefix = int(data.group(4))
offload = data.group(5) offload = data.group(5)
return ( return (
cls( cls( # type: ignore[call-arg]
v0.version, v0.version,
v0.signature, v0.signature,
v0.api, v0.api,
...@@ -201,7 +201,7 @@ class HeadV2(HeadV1): ...@@ -201,7 +201,7 @@ class HeadV2(HeadV1):
free_member_room = int(data.group(1)) free_member_room = int(data.group(1))
free_mirror_room = int(data.group(2)) free_mirror_room = int(data.group(2))
return ( return (
cls( cls( # type: ignore[call-arg]
v1.version, v1.version,
v1.signature, v1.signature,
v1.api, v1.api,
......
...@@ -28,9 +28,7 @@ def load_credentials_file(signing_key_instance=None): ...@@ -28,9 +28,7 @@ def load_credentials_file(signing_key_instance=None):
credentials_filepath = sys.argv[1] credentials_filepath = sys.argv[1]
# create SigningKey instance from file # create SigningKey instance from file
signing_key_instance = SigningKey.from_credentials_file( signing_key_instance = SigningKey.from_credentials_file(credentials_filepath)
credentials_filepath
) # type: SigningKey
# print pubkey # print pubkey
print(f"Public key from credentials file: {signing_key_instance.pubkey}") print(f"Public key from credentials file: {signing_key_instance.pubkey}")
......
...@@ -28,9 +28,7 @@ def load_scuttlebutt_file(signing_key_insance=None): ...@@ -28,9 +28,7 @@ def load_scuttlebutt_file(signing_key_insance=None):
scuttlebutt_filepath = sys.argv[1] scuttlebutt_filepath = sys.argv[1]
# create SigningKey instance from file # create SigningKey instance from file
signing_key_instance = SigningKey.from_ssb_file( signing_key_instance = SigningKey.from_ssb_file(scuttlebutt_filepath)
scuttlebutt_filepath
) # type: SigningKey
# print pubkey # print pubkey
print(f"Public key from scuttlebutt file: {signing_key_instance.pubkey}") print(f"Public key from scuttlebutt file: {signing_key_instance.pubkey}")
......
...@@ -62,9 +62,7 @@ def save_and_load_private_key_file(): ...@@ -62,9 +62,7 @@ def save_and_load_private_key_file():
print(f"Private keys for public key {pubkey} saved in {PRIVATE_KEYS_FILE_PATH}") print(f"Private keys for public key {pubkey} saved in {PRIVATE_KEYS_FILE_PATH}")
# load private keys from file # load private keys from file
loaded_signer = SigningKey.from_private_key( loaded_signer = SigningKey.from_private_key(PRIVATE_KEYS_FILE_PATH)
PRIVATE_KEYS_FILE_PATH
) # type: SigningKey
# check public key from file # check public key from file
print( print(
......
...@@ -68,9 +68,7 @@ def save_and_load_private_key_file_ewif(): ...@@ -68,9 +68,7 @@ def save_and_load_private_key_file_ewif():
try: try:
# load private keys from file # load private keys from file
loaded_signer = SigningKey.from_ewif_file( loaded_signer = SigningKey.from_ewif_file(PRIVATE_KEY_FILE_PATH, ewif_password)
PRIVATE_KEY_FILE_PATH, ewif_password
) # type: SigningKey
# check public key from file # check public key from file
print( print(
......
...@@ -65,9 +65,7 @@ def save_and_load_private_key_file_wif(): ...@@ -65,9 +65,7 @@ def save_and_load_private_key_file_wif():
try: try:
# load private keys from file # load private keys from file
loaded_signer = SigningKey.from_wif_file( loaded_signer = SigningKey.from_wif_file(PRIVATE_KEY_FILE_PATH)
PRIVATE_KEY_FILE_PATH
) # type: SigningKey
# check public key from file # check public key from file
print( print(
......
...@@ -43,7 +43,7 @@ def save_binary_signed_message(): ...@@ -43,7 +43,7 @@ def save_binary_signed_message():
# Sign the message, the signed string is the message itself plus the # Sign the message, the signed string is the message itself plus the
# signature # signature
signed_message = key.sign(bytes(message, "utf-8")) # type: bytes signed_message = key.sign(bytes(message, "utf-8"))
# To create a verifier pass in the verify key: # To create a verifier pass in the verify key:
veri = libnacl.sign.Verifier(key.hex_vk()) veri = libnacl.sign.Verifier(key.hex_vk())
......
...@@ -35,7 +35,7 @@ class TestVerifyingKey(unittest.TestCase): ...@@ -35,7 +35,7 @@ class TestVerifyingKey(unittest.TestCase):
message = "Hello world with utf-8 chars like éàè !" message = "Hello world with utf-8 chars like éàè !"
# Sign the message, the signed string is the message itself plus the # Sign the message, the signed string is the message itself plus the
# signature # signature
signed_message = sign_key.sign(bytes(message, "utf-8")) # type: bytes signed_message = sign_key.sign(bytes(message, "utf-8"))
# Verify the message! # Verify the message!
verifier = VerifyingKey(sign_key.pubkey) verifier = VerifyingKey(sign_key.pubkey)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment