From 23b58cc0cb12680663db53009a7134de3038a7ea Mon Sep 17 00:00:00 2001 From: matejcik Date: Wed, 13 Jun 2018 19:35:01 +0200 Subject: [PATCH] flake8: fix complaints --- .flake8 | 4 +++- trezorlib/client.py | 3 +-- trezorlib/device.py | 16 ++++++++-------- trezorlib/firmware.py | 2 +- trezorlib/misc.py | 27 ++++++++++++++------------- trezorlib/nem.py | 1 - trezorlib/tools.py | 1 - 7 files changed, 27 insertions(+), 27 deletions(-) diff --git a/.flake8 b/.flake8 index 5fd544793..7d1af43a8 100644 --- a/.flake8 +++ b/.flake8 @@ -19,4 +19,6 @@ ignore = # E722: do not use bare except E722, # E741: ambiguous variable name - E741 + E741, + ##### E266: too many leading '#' for block comment + E266, diff --git a/trezorlib/client.py b/trezorlib/client.py index c5604be3a..940d993f1 100644 --- a/trezorlib/client.py +++ b/trezorlib/client.py @@ -460,7 +460,6 @@ class ProtocolMixin(object): def clear_session(self): return self.call(proto.ClearSession()) - # Device functionality self_test = MovedTo(device.self_test) @@ -516,7 +515,7 @@ class ProtocolMixin(object): stellar_get_address = MovedTo(stellar.get_address) stellar_sign_transaction = MovedTo(stellar.sign_tx) - # Miscellaneous cryptography + # Miscellaneous cryptographic functionality get_entropy = MovedTo(misc.get_entropy) sign_identity = MovedTo(misc.sign_identity) get_ecdh_session_key = MovedTo(misc.get_ecdh_session_key) diff --git a/trezorlib/device.py b/trezorlib/device.py index 42a7411a5..df8a7cddf 100644 --- a/trezorlib/device.py +++ b/trezorlib/device.py @@ -183,10 +183,10 @@ def load_device_by_mnemonic(client, mnemonic, pin, passphrase_protection, label, raise RuntimeError("Device is initialized already. Call wipe_device() and try again.") resp = client.call(proto.LoadDevice(mnemonic=mnemonic, pin=pin, - passphrase_protection=passphrase_protection, - language=language, - label=label, - skip_checksum=skip_checksum)) + passphrase_protection=passphrase_protection, + language=language, + label=label, + skip_checksum=skip_checksum)) client.init_device() return resp @@ -228,10 +228,10 @@ def load_device_by_xprv(client, xprv, pin, passphrase_protection, label, languag node.private_key = binascii.unhexlify(data[92:156]) # skip 0x00 indicating privkey resp = client.call(proto.LoadDevice(node=node, - pin=pin, - passphrase_protection=passphrase_protection, - language=language, - label=label)) + pin=pin, + passphrase_protection=passphrase_protection, + language=language, + label=label)) client.init_device() return resp diff --git a/trezorlib/firmware.py b/trezorlib/firmware.py index 8f4a01693..1072deae1 100644 --- a/trezorlib/firmware.py +++ b/trezorlib/firmware.py @@ -152,7 +152,7 @@ def update(client, fp): # TREZORv1 method if isinstance(resp, proto.Success): - fingerprint = hashlib.sha256(data[256:]).hexdigest() + # fingerprint = hashlib.sha256(data[256:]).hexdigest() # LOG.debug("Firmware fingerprint: " + fingerprint) resp = client.call(proto.FirmwareUpload(payload=data)) if isinstance(resp, proto.Success): diff --git a/trezorlib/misc.py b/trezorlib/misc.py index 4d543ccd5..c559453dd 100644 --- a/trezorlib/misc.py +++ b/trezorlib/misc.py @@ -12,6 +12,7 @@ def get_entropy(client, size): def sign_identity(client, identity, challenge_hidden, challenge_visual, ecdsa_curve_name=None): return client.call(proto.SignIdentity(identity=identity, challenge_hidden=challenge_hidden, challenge_visual=challenge_visual, ecdsa_curve_name=ecdsa_curve_name)) + @expect(proto.ECDHSessionKey) def get_ecdh_session_key(client, identity, peer_public_key, ecdsa_curve_name=None): return client.call(proto.GetECDHSessionKey(identity=identity, peer_public_key=peer_public_key, ecdsa_curve_name=ecdsa_curve_name)) @@ -22,22 +23,22 @@ def get_ecdh_session_key(client, identity, peer_public_key, ecdsa_curve_name=Non def encrypt_keyvalue(client, n, key, value, ask_on_encrypt=True, ask_on_decrypt=True, iv=b''): n = client._convert_prime(n) return client.call(proto.CipherKeyValue(address_n=n, - key=key, - value=value, - encrypt=True, - ask_on_encrypt=ask_on_encrypt, - ask_on_decrypt=ask_on_decrypt, - iv=iv)) + key=key, + value=value, + encrypt=True, + ask_on_encrypt=ask_on_encrypt, + ask_on_decrypt=ask_on_decrypt, + iv=iv)) + @field('value') @expect(proto.CipheredKeyValue) def decrypt_keyvalue(client, n, key, value, ask_on_encrypt=True, ask_on_decrypt=True, iv=b''): n = client._convert_prime(n) return client.call(proto.CipherKeyValue(address_n=n, - key=key, - value=value, - encrypt=False, - ask_on_encrypt=ask_on_encrypt, - ask_on_decrypt=ask_on_decrypt, - iv=iv)) - + key=key, + value=value, + encrypt=False, + ask_on_encrypt=ask_on_encrypt, + ask_on_decrypt=ask_on_decrypt, + iv=iv)) diff --git a/trezorlib/nem.py b/trezorlib/nem.py index 570b47a63..4f7801fc3 100644 --- a/trezorlib/nem.py +++ b/trezorlib/nem.py @@ -188,4 +188,3 @@ def sign_tx(client, n, transaction): assert msg.transaction is not None msg.transaction.address_n = n return client.call(msg) - diff --git a/trezorlib/tools.py b/trezorlib/tools.py index 43770d22e..36f2358c7 100644 --- a/trezorlib/tools.py +++ b/trezorlib/tools.py @@ -162,7 +162,6 @@ def parse_path(nstr: str) -> Address: raise ValueError('Invalid BIP32 path', nstr) - def normalize_nfc(txt): ''' Normalize message to NFC and return bytes suitable for protobuf.