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

[lint] Handle new Pylint rules

Specify encoding on open()
parent 3be9fe9f
No related branches found
No related tags found
1 merge request!169Bump pre-commit hooks version, Handle new Pylint rules
Pipeline #14279 waiting for manual action
......@@ -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))
......
......@@ -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)
......
......@@ -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)
......
......@@ -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
......
......@@ -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}")
......
......@@ -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}")
......
......@@ -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}")
......
......@@ -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}")
......
......@@ -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
......
......@@ -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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment