Fix Pylint exception chaining warnings (#1519)

This commit is contained in:
Julien Maffre 2020-08-21 12:09:13 +01:00 коммит произвёл GitHub
Родитель 3909627c10
Коммит 6a3c82e653
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
6 изменённых файлов: 13 добавлений и 11 удалений

Просмотреть файл

@ -228,8 +228,8 @@ class Transaction:
self._complete_read()
self._read_header()
return self
except:
raise StopIteration()
except Exception as e:
raise StopIteration() from e
class Ledger:
@ -275,7 +275,7 @@ class Ledger:
self._current_tx = Transaction(self._filenames[self._fileindex])
return next(self._current_tx)
else:
raise StopIteration()
raise
def __iter__(self):
return self

Просмотреть файл

@ -127,7 +127,9 @@ def run_to_destruction(args):
break
if time.time() > end_time:
raise TimeoutError(f"Node took longer than {timeout}s to terminate")
raise TimeoutError(
f"Node took longer than {timeout}s to terminate"
) from e
network.ignore_errors_on_shutdown()

Просмотреть файл

@ -32,8 +32,8 @@ def run(args):
for choice in args.test_suite:
try:
chosen_suite.extend(s.suites[choice])
except KeyError:
raise ValueError(f"Unhandled choice: {choice}")
except KeyError as e:
raise ValueError(f"Unhandled choice: {choice}") from e
seed = None
if os.getenv("SHUFFLE_SUITE"):

Просмотреть файл

@ -432,7 +432,7 @@ class Network:
else infra.node.NodeStatus.TRUSTED
),
)
except TimeoutError:
except TimeoutError as e:
# The node can be safely discarded since it has not been
# attributed a unique node_id by CCF
LOG.error(f"New pending node {new_node.node_id} failed to join the network")
@ -442,7 +442,7 @@ class Network:
# Throw accurate exceptions if known errors found in
for error in errors:
if "CODE_ID_NOT_FOUND" in error:
raise CodeIdNotFound
raise CodeIdNotFound from e
raise
return new_node

Просмотреть файл

@ -244,8 +244,8 @@ class Node:
assert (
rep.status_code == 200
), f"An error occured after node {self.node_id} joined the network: {rep.body}"
except ccf.clients.CCFConnectionException:
raise TimeoutError(f"Node {self.node_id} failed to join the network")
except ccf.clients.CCFConnectionException as e:
raise TimeoutError(f"Node {self.node_id} failed to join the network") from e
def get_ledger(self):
return self.remote.get_ledger()

Просмотреть файл

@ -38,7 +38,7 @@ def ensure_reqs(check_reqs):
except Exception as e:
raise TestRequirementsNotMet(
f"Could not check if test requirements were met: {e}"
)
) from e
return func(network, args, *nargs, **kwargs)