From 9b69418efa26ca3a317495cf1258eef116649ec3 Mon Sep 17 00:00:00 2001 From: Guillaume Fieni Date: Tue, 5 Mar 2024 14:43:30 +0100 Subject: [PATCH 1/5] build(pylint): Add `info` messages to the global evaluation score --- .pylintrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pylintrc b/.pylintrc index 87493d2e..3dd7cb13 100644 --- a/.pylintrc +++ b/.pylintrc @@ -99,7 +99,7 @@ enable=c-extension-no-member,suppressed-message,useless-suppression # respectively contain the number of errors / warnings messages and the total # number of statements analyzed. This is used by the global evaluation report # (RP0004). -evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / statement) * 10) +evaluation=10.0 - ((float(5 * error + warning + refactor + convention + info) / statement) * 10) # Template used to display messages. This is a python new-style format string # used to format the message information. See doc for all details. From da6038b292766ecdfc4db9bf2a464caf00ed06a8 Mon Sep 17 00:00:00 2001 From: Guillaume Fieni Date: Tue, 5 Mar 2024 14:44:02 +0100 Subject: [PATCH 2/5] build(pylint): Enable pylint `no-else-return` check --- .pylintrc | 1 - 1 file changed, 1 deletion(-) diff --git a/.pylintrc b/.pylintrc index 3dd7cb13..942be508 100644 --- a/.pylintrc +++ b/.pylintrc @@ -78,7 +78,6 @@ disable=raw-checker-failed, empty-docstring, invalid-name, dangerous-default-value, - no-else-return, no-else-raise, invalid-overridden-method, abstract-method, From 14c2d3e124a4793331834a6d83795727ed82b5bd Mon Sep 17 00:00:00 2001 From: Guillaume Fieni Date: Tue, 5 Mar 2024 14:52:13 +0100 Subject: [PATCH 3/5] refactor(utils): Fix pylint `no-else-return` warning --- src/powerapi/utils/stat_buffer.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/powerapi/utils/stat_buffer.py b/src/powerapi/utils/stat_buffer.py index 58d7b70a..ed0e5709 100644 --- a/src/powerapi/utils/stat_buffer.py +++ b/src/powerapi/utils/stat_buffer.py @@ -86,14 +86,15 @@ def _split_values(self, values: List[Dict]): time_of_first_measure = values[0]['time'] def split(value_in_periode, value_out_periode): - if value_out_periode == []: + if not value_out_periode: return value_in_periode, value_out_periode + if value_out_periode[0]['time'] - time_of_first_measure > self.aggregation_periode: return value_in_periode, value_out_periode - else: - val = value_out_periode.pop(0) - value_in_periode.append(val) - return split(value_in_periode, value_out_periode) + + val = value_out_periode.pop(0) + value_in_periode.append(val) + return split(value_in_periode, value_out_periode) return split([], values) From 944cfec8a847f10f9cb90269d440d2ec5ed8560f Mon Sep 17 00:00:00 2001 From: Guillaume Fieni Date: Tue, 5 Mar 2024 14:52:27 +0100 Subject: [PATCH 4/5] refactor(actor): Fix pylint `no-else-return` warning --- src/powerapi/actor/socket_interface.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/powerapi/actor/socket_interface.py b/src/powerapi/actor/socket_interface.py index f8321ff3..5fa01b28 100644 --- a/src/powerapi/actor/socket_interface.py +++ b/src/powerapi/actor/socket_interface.py @@ -158,11 +158,13 @@ def receive(self): """ events = self.poller.poll(self.timeout) - # If there is control socket, he has the priority + # If there is data available on both sockets, the control one has priority if len(events) == 2: return self._recv_serialized(self.control_socket) - elif len(events) == 1: + + if len(events) == 1: return self._recv_serialized(events[0][0]) + return None def receive_control(self, timeout): From 7b1cc433ed20ba51b1f03f9c932ba1780fb04e77 Mon Sep 17 00:00:00 2001 From: Guillaume Fieni Date: Tue, 5 Mar 2024 14:52:33 +0100 Subject: [PATCH 5/5] refactor(puller): Fix pylint `no-else-return` warning --- src/powerapi/puller/handlers.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/powerapi/puller/handlers.py b/src/powerapi/puller/handlers.py index 5535c76f..6083b0cb 100644 --- a/src/powerapi/puller/handlers.py +++ b/src/powerapi/puller/handlers.py @@ -74,12 +74,11 @@ def _pull_database(self): try: if self.state.asynchrone: report = self.loop.run_until_complete(self.state.database_it.__anext__()) - if report is not None: - return report - else: + if report is None: raise StopIteration() - else: - return next(self.state.database_it) + return report + + return next(self.state.database_it) except (StopIteration, BadInputData, DeserializationFail) as database_problem: raise NoReportExtractedException() from database_problem