From 8c2ff37c7e12617e1150a30bd7d027a2ba71678a Mon Sep 17 00:00:00 2001 From: Moul <moul@moul.re> Date: Fri, 26 May 2023 19:16:17 +0200 Subject: [PATCH] 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 --- .pre-commit-config.yaml | 2 +- duniterpy/documents/ws2p/heads.py | 10 +++++----- examples/load_credentials_file.py | 4 +--- examples/load_scuttlebutt_file.py | 4 +--- examples/save_and_load_private_key_file.py | 4 +--- examples/save_and_load_private_key_file_ewif.py | 4 +--- examples/save_and_load_private_key_file_wif.py | 4 +--- examples/save_binary_signed_message.py | 2 +- tests/key/test_verifying_key.py | 2 +- 9 files changed, 13 insertions(+), 23 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 951ac5b..ae67494 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,7 +10,7 @@ repos: - id: isort args: ["--profile", "black"] - repo: https://github.com/pre-commit/mirrors-mypy - rev: v0.991 + rev: v1.3.0 hooks: - id: mypy args: diff --git a/duniterpy/documents/ws2p/heads.py b/duniterpy/documents/ws2p/heads.py index 04cc8d0..9f6a3ec 100644 --- a/duniterpy/documents/ws2p/heads.py +++ b/duniterpy/documents/ws2p/heads.py @@ -48,7 +48,7 @@ class API: raise MalformedDocumentError("WS2P API Document") private = "" if data.group(1) is None else data.group(1) 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: return f"WS2P{self.private}{self.public}" @@ -68,7 +68,7 @@ class Head: raise MalformedDocumentError("Head") head = data.group(0).split(":") version = int(head[1]) if len(head) == 2 else 0 - return cls(version) + return cls(version) # type: ignore[call-arg] except AttributeError: raise MalformedDocumentError("Head") from AttributeError @@ -102,7 +102,7 @@ class HeadV0(Head): pubkey = data.group(3) block_id = BlockID.from_str(data.group(4)) 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: raise MalformedDocumentError("HeadV0") from AttributeError @@ -162,7 +162,7 @@ class HeadV1(HeadV0): pow_prefix = int(data.group(4)) offload = data.group(5) return ( - cls( + cls( # type: ignore[call-arg] v0.version, v0.signature, v0.api, @@ -201,7 +201,7 @@ class HeadV2(HeadV1): free_member_room = int(data.group(1)) free_mirror_room = int(data.group(2)) return ( - cls( + cls( # type: ignore[call-arg] v1.version, v1.signature, v1.api, diff --git a/examples/load_credentials_file.py b/examples/load_credentials_file.py index bf3788b..1d32eaf 100644 --- a/examples/load_credentials_file.py +++ b/examples/load_credentials_file.py @@ -28,9 +28,7 @@ def load_credentials_file(signing_key_instance=None): credentials_filepath = sys.argv[1] # create SigningKey instance from file - signing_key_instance = SigningKey.from_credentials_file( - credentials_filepath - ) # type: SigningKey + signing_key_instance = SigningKey.from_credentials_file(credentials_filepath) # print pubkey print(f"Public key from credentials file: {signing_key_instance.pubkey}") diff --git a/examples/load_scuttlebutt_file.py b/examples/load_scuttlebutt_file.py index f36ce1e..def5c10 100644 --- a/examples/load_scuttlebutt_file.py +++ b/examples/load_scuttlebutt_file.py @@ -28,9 +28,7 @@ def load_scuttlebutt_file(signing_key_insance=None): scuttlebutt_filepath = sys.argv[1] # create SigningKey instance from file - signing_key_instance = SigningKey.from_ssb_file( - scuttlebutt_filepath - ) # type: SigningKey + signing_key_instance = SigningKey.from_ssb_file(scuttlebutt_filepath) # print pubkey print(f"Public key from scuttlebutt file: {signing_key_instance.pubkey}") diff --git a/examples/save_and_load_private_key_file.py b/examples/save_and_load_private_key_file.py index 096337a..b40c77c 100644 --- a/examples/save_and_load_private_key_file.py +++ b/examples/save_and_load_private_key_file.py @@ -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}") # load private keys from file - loaded_signer = SigningKey.from_private_key( - PRIVATE_KEYS_FILE_PATH - ) # type: SigningKey + loaded_signer = SigningKey.from_private_key(PRIVATE_KEYS_FILE_PATH) # check public key from file print( diff --git a/examples/save_and_load_private_key_file_ewif.py b/examples/save_and_load_private_key_file_ewif.py index ef52e78..e25c987 100644 --- a/examples/save_and_load_private_key_file_ewif.py +++ b/examples/save_and_load_private_key_file_ewif.py @@ -68,9 +68,7 @@ def save_and_load_private_key_file_ewif(): try: # load private keys from file - loaded_signer = SigningKey.from_ewif_file( - PRIVATE_KEY_FILE_PATH, ewif_password - ) # type: SigningKey + loaded_signer = SigningKey.from_ewif_file(PRIVATE_KEY_FILE_PATH, ewif_password) # check public key from file print( diff --git a/examples/save_and_load_private_key_file_wif.py b/examples/save_and_load_private_key_file_wif.py index a334e49..ee7ef18 100644 --- a/examples/save_and_load_private_key_file_wif.py +++ b/examples/save_and_load_private_key_file_wif.py @@ -65,9 +65,7 @@ def save_and_load_private_key_file_wif(): try: # load private keys from file - loaded_signer = SigningKey.from_wif_file( - PRIVATE_KEY_FILE_PATH - ) # type: SigningKey + loaded_signer = SigningKey.from_wif_file(PRIVATE_KEY_FILE_PATH) # check public key from file print( diff --git a/examples/save_binary_signed_message.py b/examples/save_binary_signed_message.py index 6ad82a1..5f730cc 100644 --- a/examples/save_binary_signed_message.py +++ b/examples/save_binary_signed_message.py @@ -43,7 +43,7 @@ def save_binary_signed_message(): # Sign the message, the signed string is the message itself plus the # 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: veri = libnacl.sign.Verifier(key.hex_vk()) diff --git a/tests/key/test_verifying_key.py b/tests/key/test_verifying_key.py index 488715b..8dac301 100644 --- a/tests/key/test_verifying_key.py +++ b/tests/key/test_verifying_key.py @@ -35,7 +35,7 @@ class TestVerifyingKey(unittest.TestCase): message = "Hello world with utf-8 chars like éàè !" # Sign the message, the signed string is the message itself plus the # signature - signed_message = sign_key.sign(bytes(message, "utf-8")) # type: bytes + signed_message = sign_key.sign(bytes(message, "utf-8")) # Verify the message! verifier = VerifyingKey(sign_key.pubkey) -- GitLab