diff --git a/duniterpy/api/client.py b/duniterpy/api/client.py index e0fac12a6d492b14e4e9c34898c3b57624e1c81c..a6831179c94728956e8481a4385f35bd91175809 100644 --- a/duniterpy/api/client.py +++ b/duniterpy/api/client.py @@ -351,7 +351,7 @@ class Client: :return: """ if params is None: - params = dict() + params = {} client = API(self.endpoint.conn_handler(self.proxy)) @@ -377,7 +377,7 @@ class Client: :return: """ if params is None: - params = dict() + params = {} client = API(self.endpoint.conn_handler(self.proxy)) diff --git a/duniterpy/documents/transaction.py b/duniterpy/documents/transaction.py index d13de2b9874ca521f43bb2a70fd09b7f37e898a5..edae5941e8d719bdb6d88cdae6d49b5c173ffb11 100644 --- a/duniterpy/documents/transaction.py +++ b/duniterpy/documents/transaction.py @@ -564,7 +564,7 @@ class Transaction(Document): self.outputs = outputs self.comment = comment self.time = time - self.signatures: List[str] = list() + self.signatures: List[str] = [] if signing_keys: self.multi_sign(signing_keys) diff --git a/duniterpy/helpers/blockchain.py b/duniterpy/helpers/blockchain.py index 71fcca316e79b34ae472eb2cc048c0b5def52cc5..94b0ff06575f756c070684d7f1d1b7311f96e772 100644 --- a/duniterpy/helpers/blockchain.py +++ b/duniterpy/helpers/blockchain.py @@ -38,7 +38,8 @@ class JsonBlockchain: with open( self.folder.joinpath( f"chunk_{str(self.current_chunk)}-{str(CHUNK_SIZE)}.json" - ) + ), + encoding="utf-8", ) as f: s = f.read() p = json.loads(s) diff --git a/duniterpy/key/signing_key.py b/duniterpy/key/signing_key.py index ccad9f035e7f0673db20d5008d2f8ec053ed1b19..3737d0d517ece753d85d18fa978566b67a3caef9 100644 --- a/duniterpy/key/signing_key.py +++ b/duniterpy/key/signing_key.py @@ -89,7 +89,7 @@ class SigningKey(libnacl.sign.Signer): :return: """ # capture credentials from file - with open(path) as fh: + with open(path, encoding="utf-8") as fh: lines = fh.readlines() assert len(lines) > 1 salt = lines[0].strip() @@ -104,7 +104,7 @@ class SigningKey(libnacl.sign.Signer): :param path: Authentication file path """ seedhex = convert_seed_to_seedhex(self.seed) - with open(path, "w") as fh: + with open(path, "w", encoding="utf-8") as fh: fh.write(seedhex) @staticmethod @@ -114,7 +114,7 @@ class SigningKey(libnacl.sign.Signer): :param str path: Hexadecimal seed file path """ - with open(path) as fh: + with open(path, encoding="utf-8") as fh: seedhex = fh.read() return SigningKey.from_seedhex(seedhex) @@ -174,7 +174,7 @@ class SigningKey(libnacl.sign.Signer): :param path: Path to WIF file """ - with open(path) as fh: + with open(path, encoding="utf-8") as fh: pubsec_content = fh.read() # line patterns @@ -216,7 +216,7 @@ class SigningKey(libnacl.sign.Signer): Version: {version}\n\ pub: {self.pubkey}\n\ sec: {base58_signing_key}" - with open(path, "w") as fh: + with open(path, "w", encoding="utf-8") as fh: fh.write(content) @staticmethod @@ -229,7 +229,7 @@ sec: {base58_signing_key}" :param path: Path to WIF of EWIF file :param password: Password needed for EWIF file """ - with open(path) as fh: + with open(path, encoding="utf-8") as fh: wif_content = fh.read() # check data field @@ -272,7 +272,7 @@ sec: {base58_signing_key}" :param path: Path to WIF file """ - with open(path) as fh: + with open(path, encoding="utf-8") as fh: wif_content = fh.read() # check data field @@ -336,7 +336,7 @@ sec: {base58_signing_key}" content = f"Type: WIF\n\ Version: {version}\n\ Data: {wif_key}" - with open(path, "w") as fh: + with open(path, "w", encoding="utf-8") as fh: fh.write(content) @staticmethod @@ -347,7 +347,7 @@ Data: {wif_key}" :param path: Path to EWIF file :param password: Password of the encrypted seed """ - with open(path) as fh: + with open(path, encoding="utf-8") as fh: wif_content = fh.read() # check data field @@ -466,7 +466,7 @@ Data: {wif_key}" content = f"Type: EWIF\n\ Version: {version}\n\ Data: {ewif_key}" - with open(path, "w") as fh: + with open(path, "w", encoding="utf-8") as fh: fh.write(content) @classmethod @@ -476,7 +476,7 @@ Data: {ewif_key}" :param path: Path to Scuttlebutt secret file """ - with open(path) as fh: + with open(path, encoding="utf-8") as fh: ssb_content = fh.read() # check data field diff --git a/examples/load_cleartext_ascii_armor_message.py b/examples/load_cleartext_ascii_armor_message.py index 0e1aafd8fa56e4cc0d56cb53ef6cf8c0b9965a5a..9300b0ea757452d47992f70ad6eec34a031c778c 100644 --- a/examples/load_cleartext_ascii_armor_message.py +++ b/examples/load_cleartext_ascii_armor_message.py @@ -27,7 +27,7 @@ def load_cleartext_ascii_armor_message(): pubkeyBase58 = input("Enter public key of the message issuer: ") # Load cleartext ascii armor message from a file - with open(CLEARTEXT_AA_MESSAGE_PATH) as file_handler: + with open(CLEARTEXT_AA_MESSAGE_PATH, encoding="utf-8") as file_handler: ascii_armor_block = file_handler.read() print(f"Cleartext Ascii Armor Message loaded from file {CLEARTEXT_AA_MESSAGE_PATH}") diff --git a/examples/load_encrypted_ascii_armor_message.py b/examples/load_encrypted_ascii_armor_message.py index b1a11597c5aa40f2a449b915e5031468c2e78000..f5182676eaef3da4128fb2aa4edf5b3925acf6a7 100644 --- a/examples/load_encrypted_ascii_armor_message.py +++ b/examples/load_encrypted_ascii_armor_message.py @@ -38,7 +38,7 @@ def load_encrypted_ascii_armor_message(): signing_key = SigningKey.from_credentials(salt, password) # Load ascii armor encrypted message from a file - with open(ENCRYPTED_AA_MESSAGE_PATH) as file_handler: + with open(ENCRYPTED_AA_MESSAGE_PATH, encoding="utf-8") as file_handler: ascii_armor_block = file_handler.read() print(f"Encrypted Ascii Armor Message loaded from file {ENCRYPTED_AA_MESSAGE_PATH}") diff --git a/examples/save_cleartext_ascii_armor_message.py b/examples/save_cleartext_ascii_armor_message.py index 0a07351bb1954d227398228e1f84a16bb72bdfef..752d8deed5f81254f00147d722426f3ceb1a5df9 100644 --- a/examples/save_cleartext_ascii_armor_message.py +++ b/examples/save_cleartext_ascii_armor_message.py @@ -49,7 +49,7 @@ def save_cleartext_ascii_armor_message(): ) # Save cleartext ascii armor message in a file - with open(CLEARTEXT_AA_MESSAGE_PATH, "w") as file_handler: + with open(CLEARTEXT_AA_MESSAGE_PATH, "w", encoding="utf-8") as file_handler: file_handler.write(aa_cleartext_message) print(f"Cleartext Ascii Armor Message saved in file {CLEARTEXT_AA_MESSAGE_PATH}") diff --git a/examples/save_encrypted_ascii_armor_message.py b/examples/save_encrypted_ascii_armor_message.py index cd417934cc78136ffe55b6950c85fb183a310864..cf3347cc466e1993886d69b5916df6f0ea32478b 100644 --- a/examples/save_encrypted_ascii_armor_message.py +++ b/examples/save_encrypted_ascii_armor_message.py @@ -54,7 +54,7 @@ def save_encrypted_ascii_armor_message(): ) # Save encrypted message in a file - with open(ENCRYPTED_AA_MESSAGE_PATH, "w") as file_handler: + with open(ENCRYPTED_AA_MESSAGE_PATH, "w", encoding="utf-8") as file_handler: file_handler.write(encrypted_message) print(f"Encrypted Ascii Armor Message saved in file {ENCRYPTED_AA_MESSAGE_PATH}") diff --git a/examples/save_revoke_document.py b/examples/save_revoke_document.py index 22b4fcb1117116402d6c3a006b9d00e9d0c7ca9a..79bc7bab26f3ba223e3f55f2b8c9f2a51ff96db3 100644 --- a/examples/save_revoke_document.py +++ b/examples/save_revoke_document.py @@ -130,7 +130,7 @@ def save_revoke_document(): ) # save revoke document in a file - with open(REVOCATION_DOCUMENT_FILE_PATH, "w") as fp: + with open(REVOCATION_DOCUMENT_FILE_PATH, "w", encoding="utf-8") as fp: fp.write(revocation_signed_raw_document) # document saved diff --git a/tests/key/test_signing_key.py b/tests/key/test_signing_key.py index 3bfbb9005b8ae51ac7f968f15c8bda030f46afe8..256c5a66cba7d57120cc9745fcce01c3ae2fa2fc 100644 --- a/tests/key/test_signing_key.py +++ b/tests/key/test_signing_key.py @@ -98,7 +98,7 @@ class TestSigningKey(unittest.TestCase): salt = password = "test" # create a dummy credentials file - with open(TEST_FILE_PATH, "w") as fh: + with open(TEST_FILE_PATH, "w", encoding="utf-8") as fh: fh.write(f"{salt}\n{password}\n") # same key from credentials @@ -128,7 +128,7 @@ class TestSigningKey(unittest.TestCase): """ # create dummy .ssb/secret file - with open(TEST_FILE_PATH, "w") as fh: + with open(TEST_FILE_PATH, "w", encoding="utf-8") as fh: fh.write(dummy_content) # test load file sign_key_load = SigningKey.from_credentials_file(TEST_FILE_PATH)