From: Arnaud Giersch Date: Mon, 8 Feb 2021 14:53:21 +0000 (+0100) Subject: Unnecessary "else" after "return". X-Git-Tag: v3.27~417 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/05684e87676134c4b9f46cc314c63b4a53312a06?hp=967dfbd9ab81205d45a2984e54bad6b60c2e3c2c Unnecessary "else" after "return". --- diff --git a/tools/tesh/tesh.py b/tools/tesh/tesh.py index e2f44067db..9f0ef53145 100755 --- a/tools/tesh/tesh.py +++ b/tools/tesh/tesh.py @@ -278,17 +278,16 @@ class Cmd(object): # Return False if nothing has been ran. def run_if_possible(self): - if self.can_run(): - if self.background: - lock = _thread.allocate_lock() - lock.acquire() - TeshState().add_thread(lock) - _thread.start_new_thread(Cmd._run, (self, lock)) - else: - self._run() - return True - else: + if not self.can_run(): return False + if self.background: + lock = _thread.allocate_lock() + lock.acquire() + TeshState().add_thread(lock) + _thread.start_new_thread(Cmd._run, (self, lock)) + else: + self._run() + return True def _run(self, lock=None): # Python threads loose the cwd @@ -482,15 +481,15 @@ class Cmd(object): return_code = max(2, return_code) print('\n'.join(logs)) return - else: - logs.append("Test suite `{file}': NOK (<{cmd}> got signal {sig})".format( - file=FileReader().filename, cmd=cmdName, - sig=SIGNALS_TO_NAMES_DICT[-proc.returncode])) - if lock is not None: - lock.release() - return_code = max(max(-proc.returncode, 1), return_code) - print('\n'.join(logs)) - return + + logs.append("Test suite `{file}': NOK (<{cmd}> got signal {sig})".format( + file=FileReader().filename, cmd=cmdName, + sig=SIGNALS_TO_NAMES_DICT[-proc.returncode])) + if lock is not None: + lock.release() + return_code = max(max(-proc.returncode, 1), return_code) + print('\n'.join(logs)) + return if lock is not None: lock.release()