1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-26 08:08:51 +00:00

src: fix flake8 style

This commit is contained in:
Pavol Rusnak 2017-12-09 18:38:36 +01:00
parent 8a8450d6be
commit 16bc1c6cb6
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
9 changed files with 28 additions and 25 deletions

View File

@ -11,6 +11,8 @@ ignore =
# E501: line too long
E501,
# F403: star import used, unable to detect undefined names
E741,
# E741 ambiguous variable name
F403,
# F405: name may be undefined, or defined from star imports
F405

View File

@ -415,7 +415,7 @@ class ConfirmContent(ui.Widget):
name = knownapps.knownapps[app_id]
try:
icon = res.load('apps/fido_u2f/res/u2f_%s.toif' % name.lower().replace(' ', '_'))
except:
except FileNotFoundError:
icon = res.load('apps/fido_u2f/res/u2f_generic.toif')
else:
name = '%s...%s' % (ubinascii.hexlify(app_id[:4]), ubinascii.hexlify(app_id[-4:]))

View File

@ -23,4 +23,5 @@ async def _show_entropy(ctx):
await require_confirm(ctx, Text(
'Confirm entropy', ui.ICON_RESET,
ui.BOLD, 'Do you really want', 'to send entropy?',
ui.NORMAL, 'Continue only if you', 'know what you are doing!'),code=ProtectCall)
ui.NORMAL, 'Continue only if you', 'know what you are doing!'),
code=ProtectCall)

View File

@ -131,4 +131,3 @@ def sanitize_tx_output(tx: TransactionType) -> TxOutputType:
def sanitize_tx_binoutput(tx: TransactionType) -> TxOutputBinType:
return tx.bin_outputs[0]

View File

@ -4,6 +4,7 @@ from trezor.messages import InputScriptType, FailureType
from apps.wallet.sign_tx.writers import *
class Bip143Error(ValueError):
pass

View File

@ -414,10 +414,10 @@ def output_is_change(o: TxOutputType, wallet_path: list, segwit_in: int) -> bool
# segwit inputs paid. this is to prevent user being tricked into
# creating ANYONECANSPEND outputs before full segwit activation.
return False
return (address_n is not None and wallet_path is not None
and wallet_path == address_n[:-_BIP32_WALLET_DEPTH]
and address_n[-2] == _BIP32_CHANGE_CHAIN
and address_n[-1] <= _BIP32_MAX_LAST_ELEMENT)
return (address_n is not None and wallet_path is not None and
wallet_path == address_n[:-_BIP32_WALLET_DEPTH] and
address_n[-2] == _BIP32_CHANGE_CHAIN and
address_n[-1] <= _BIP32_MAX_LAST_ELEMENT)
# Tx Inputs

View File

@ -38,10 +38,10 @@ class TxWeightCalculator:
def __init__(self, inputs_count: int, outputs_count: int):
self.inputs_count = inputs_count
self.counter = 4 * (
_TXSIZE_HEADER
+ _TXSIZE_FOOTER
+ self.ser_length_size(inputs_count)
+ self.ser_length_size(outputs_count))
_TXSIZE_HEADER +
_TXSIZE_FOOTER +
self.ser_length_size(inputs_count) +
self.ser_length_size(outputs_count))
self.segwit = False
def add_witness_header(self):
@ -54,25 +54,25 @@ class TxWeightCalculator:
if i.multisig:
multisig_script_size = (
_TXSIZE_MULTISIGSCRIPT
+ i.multisig.pubkeys_count * (1 + _TXSIZE_PUBKEY))
_TXSIZE_MULTISIGSCRIPT +
i.multisig.pubkeys_count * (1 + _TXSIZE_PUBKEY))
input_script_size = (
1 # the OP_FALSE bug in multisig
+ i.multisig.m * (1 + _TXSIZE_SIGNATURE)
+ self.op_push_size(multisig_script_size)
+ multisig_script_size)
1 + # the OP_FALSE bug in multisig
i.multisig.m * (1 + _TXSIZE_SIGNATURE) +
self.op_push_size(multisig_script_size) +
multisig_script_size)
else:
input_script_size = 1 + _TXSIZE_SIGNATURE + 1 + _TXSIZE_PUBKEY
self.counter += 4 * _TXSIZE_INPUT
if (i.script_type == InputScriptType.SPENDADDRESS
or i.script_type == InputScriptType.SPENDMULTISIG):
if (i.script_type == InputScriptType.SPENDADDRESS or
i.script_type == InputScriptType.SPENDMULTISIG):
input_script_size += self.ser_length_size(input_script_size)
self.counter += 4 * input_script_size
elif (i.script_type == InputScriptType.SPENDWITNESS
or i.script_type == InputScriptType.SPENDP2SHWITNESS):
elif (i.script_type == InputScriptType.SPENDWITNESS or
i.script_type == InputScriptType.SPENDP2SHWITNESS):
self.add_witness_header()
if i.script_type == InputScriptType.SPENDP2SHWITNESS:
if i.multisig:

View File

@ -68,10 +68,10 @@ def bech32_decode(bech):
pos = bech.rfind('1')
if pos < 1 or pos + 7 > len(bech) or len(bech) > 90:
return (None, None)
if not all(x in CHARSET for x in bech[pos+1:]):
if not all(x in CHARSET for x in bech[pos + 1:]):
return (None, None)
hrp = bech[:pos]
data = [CHARSET.find(x) for x in bech[pos+1:]]
data = [CHARSET.find(x) for x in bech[pos + 1:]]
if not bech32_verify_checksum(hrp, data):
return (None, None)
return (hrp, data[:-6])
@ -120,4 +120,4 @@ def encode(hrp, witver, witprog):
ret = bech32_encode(hrp, [witver] + convertbits(witprog, 8, 5))
if decode(hrp, ret) == (None, None):
return None
return ret
return ret

View File

@ -285,7 +285,7 @@ class wait(Syscall):
def __iter__(self):
try:
return (yield self)
except:
except Exception:
# exception was raised on the waiting task externally with
# close() or throw(), kill the children tasks and re-raise
self.exit()