Skip to content

Commit

Permalink
Merge pull request #264 from powerapi-ng/refactor/fix-pylint-no-else-…
Browse files Browse the repository at this point in the history
…return

refactor: Fix pylint `no-else-return` warnings
  • Loading branch information
gfieni authored Mar 5, 2024
2 parents f0e0135 + 7b1cc43 commit 04940bf
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
3 changes: 1 addition & 2 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -99,7 +98,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.
Expand Down
6 changes: 4 additions & 2 deletions src/powerapi/actor/socket_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
9 changes: 4 additions & 5 deletions src/powerapi/puller/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 6 additions & 5 deletions src/powerapi/utils/stat_buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 04940bf

Please sign in to comment.