Fix F841 local variable is assigned to but never used
Remove or unassign unused variables as listed by `flake8 --select=F841`
This commit is contained in:
parent
709694b298
commit
9042e22079
@ -181,7 +181,6 @@ def process_commands(cli_args):
|
||||
udevrules_parser.set_defaults(func=install_udev_rules_handler)
|
||||
|
||||
if any(arg == '--stdin' for arg in cli_args):
|
||||
blank_count = 0
|
||||
while True:
|
||||
try:
|
||||
line = input()
|
||||
|
||||
@ -22,7 +22,7 @@ def get_client(device_type, device_path, password=''):
|
||||
imported_dev = importlib.import_module('.devices.' + module, __package__)
|
||||
client_constructor = getattr(imported_dev, class_name + 'Client')
|
||||
client = client_constructor(device_path, password)
|
||||
except ImportError as e:
|
||||
except ImportError:
|
||||
if client:
|
||||
client.close()
|
||||
raise UnknownDeviceError('Unknown device type specified')
|
||||
@ -37,7 +37,7 @@ def enumerate(password=''):
|
||||
try:
|
||||
imported_dev = importlib.import_module('.devices.' + module, __package__)
|
||||
result.extend(imported_dev.enumerate(password))
|
||||
except ImportError as e:
|
||||
except ImportError:
|
||||
pass # Ignore ImportErrors, the user may not have all device dependencies installed
|
||||
return result
|
||||
|
||||
|
||||
@ -26,7 +26,7 @@ def coldcard_exception(f):
|
||||
return f(*args, **kwargs)
|
||||
except CCProtoError as e:
|
||||
raise BadArgumentError(str(e))
|
||||
except CCUserRefused as e:
|
||||
except CCUserRefused:
|
||||
raise ActionCanceledError('{} canceled'.format(f.__name__))
|
||||
except CCBusyError as e:
|
||||
raise DeviceBusyError(str(e))
|
||||
@ -72,7 +72,6 @@ class ColdcardClient(HardwareWalletClient):
|
||||
fd = io.BytesIO(base64.b64decode(tx.serialize()))
|
||||
|
||||
# learn size (portable way)
|
||||
offset = 0
|
||||
sz = fd.seek(0, 2)
|
||||
fd.seek(0)
|
||||
|
||||
|
||||
@ -334,7 +334,6 @@ class DigitalbitboxClient(HardwareWalletClient):
|
||||
sighash_tuples = []
|
||||
for txin, psbt_in, i_num in zip(blank_tx.vin, tx.inputs, range(len(blank_tx.vin))):
|
||||
sighash = b""
|
||||
pubkeys = []
|
||||
if psbt_in.non_witness_utxo:
|
||||
utxo = psbt_in.non_witness_utxo.vout[txin.prevout.n]
|
||||
|
||||
@ -579,7 +578,7 @@ def enumerate(password=''):
|
||||
# Try connecting to simulator
|
||||
try:
|
||||
dev = BitboxSimulator('127.0.0.1', 35345)
|
||||
res = dev.send_recv(b'{"device" : "info"}')
|
||||
dev.send_recv(b'{"device" : "info"}')
|
||||
devices.append({'path': b'udp:127.0.0.1:35345', 'interface_number': 0})
|
||||
dev.close()
|
||||
except:
|
||||
|
||||
@ -250,7 +250,7 @@ class LedgerClient(HardwareWalletClient):
|
||||
self.app.startUntrustedTransaction(i == 0, i, segwit_inputs, blank_script_code, c_tx.nVersion)
|
||||
|
||||
# Number of unused fields for Nano S, only changepath and transaction in bytes req
|
||||
outputData = self.app.finalizeInput(b"DUMMY", -1, -1, change_path, tx_bytes)
|
||||
self.app.finalizeInput(b"DUMMY", -1, -1, change_path, tx_bytes)
|
||||
|
||||
# For each input we control do segwit signature
|
||||
for i in range(len(segwit_inputs)):
|
||||
@ -267,7 +267,7 @@ class LedgerClient(HardwareWalletClient):
|
||||
for signature_attempt in all_signature_attempts[i]:
|
||||
assert(tx.inputs[i].non_witness_utxo is not None)
|
||||
self.app.startUntrustedTransaction(first_input, i, legacy_inputs, script_codes[i], c_tx.nVersion)
|
||||
outputData = self.app.finalizeInput(b"DUMMY", -1, -1, change_path, tx_bytes)
|
||||
self.app.finalizeInput(b"DUMMY", -1, -1, change_path, tx_bytes)
|
||||
tx.inputs[i].partial_sigs[signature_attempt[1]] = self.app.untrustedHashSign(signature_attempt[0], "", c_tx.nLockTime, 0x01)
|
||||
first_input = False
|
||||
|
||||
|
||||
@ -726,9 +726,6 @@ class PSBT(object):
|
||||
raise PSBTSerializationError("invalid magic")
|
||||
|
||||
# Read loop
|
||||
separators = 0
|
||||
psbt_input = PartiallySignedInput()
|
||||
in_globals = True
|
||||
while True:
|
||||
# read the key
|
||||
try:
|
||||
|
||||
@ -13,7 +13,7 @@ class UDevInstaller(object):
|
||||
udev_installer.trigger()
|
||||
udev_installer.reload_rules()
|
||||
udev_installer.add_user_plugdev_group()
|
||||
except CalledProcessError as e:
|
||||
except CalledProcessError:
|
||||
if geteuid() != 0:
|
||||
return {'error': 'Need to be root.', 'code': NEED_TO_BE_ROOT}
|
||||
raise
|
||||
|
||||
@ -14,7 +14,7 @@ from test_device import DeviceTestCase, start_bitcoind, TestDeviceConnect, TestD
|
||||
|
||||
def coldcard_test_suite(simulator, rpc, userpass, interface):
|
||||
# Start the Coldcard simulator
|
||||
simulator_proc = subprocess.Popen(['python3', os.path.basename(simulator)], cwd=os.path.dirname(simulator), stdout=subprocess.DEVNULL)
|
||||
subprocess.Popen(['python3', os.path.basename(simulator)], cwd=os.path.dirname(simulator), stdout=subprocess.DEVNULL)
|
||||
# Wait for simulator to be up
|
||||
while True:
|
||||
enum_res = process_commands(['enumerate'])
|
||||
@ -30,7 +30,7 @@ def coldcard_test_suite(simulator, rpc, userpass, interface):
|
||||
|
||||
def cleanup_simulator():
|
||||
dev = ColdcardDevice(sn='/tmp/ckcc-simulator.sock')
|
||||
resp = dev.send_recv(CCProtocolPacker.logout())
|
||||
dev.send_recv(CCProtocolPacker.logout())
|
||||
atexit.register(cleanup_simulator)
|
||||
|
||||
# Coldcard specific management command tests
|
||||
|
||||
@ -45,7 +45,7 @@ def start_bitcoind(bitcoind_path):
|
||||
try:
|
||||
rpc.getblockchaininfo()
|
||||
ready = True
|
||||
except JSONRPCException as e:
|
||||
except JSONRPCException:
|
||||
time.sleep(0.5)
|
||||
pass
|
||||
|
||||
@ -451,7 +451,7 @@ class TestSignTx(DeviceTestCase):
|
||||
else:
|
||||
self.assertNotIn('code', result)
|
||||
self.assertNotIn('error', result)
|
||||
except OSError as e:
|
||||
except OSError:
|
||||
if self.interface == 'cli':
|
||||
pass
|
||||
|
||||
|
||||
@ -16,7 +16,7 @@ class TestPSBT(unittest.TestCase):
|
||||
def test_invalid_psbt(self):
|
||||
for invalid in self.data['invalid']:
|
||||
with self.subTest(invalid=invalid):
|
||||
with self.assertRaises(PSBTSerializationError) as cm:
|
||||
with self.assertRaises(PSBTSerializationError):
|
||||
psbt = PSBT()
|
||||
psbt.deserialize(invalid)
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user