Skip to content

Commit 3e2f839

Browse files
committed
ruff: Fix TRY300 Consider moving this statement to an else block.
Signed-off-by: Anders Kaseorg <[email protected]>
1 parent 165581a commit 3e2f839

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

zulip/integrations/google/google-calendar

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,7 @@ def get_credentials() -> client.Credentials:
102102
credential_path = os.path.join(HOME_DIR, "google-credentials.json")
103103

104104
store = Storage(credential_path)
105-
credentials = store.get()
106-
107-
return credentials
105+
return store.get()
108106
except client.Error:
109107
logging.exception("Error while trying to open the `google-credentials.json` file.")
110108
sys.exit(1)

zulip/integrations/zephyr/zephyr_mirror_backend.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -577,11 +577,12 @@ def zephyr_init_autoretry() -> None:
577577
zephyr_port = c_ushort()
578578
zephyr_ctypes.check(zephyr_ctypes.ZOpenPort(byref(zephyr_port)))
579579
zephyr_ctypes.check(zephyr_ctypes.ZCancelSubscriptions(0))
580-
backoff.succeed()
581-
return
582580
except zephyr_ctypes.ZephyrError:
583581
logger.exception("Error initializing Zephyr library (retrying). Traceback:")
584582
backoff.fail()
583+
else:
584+
backoff.succeed()
585+
return
585586

586587
quit_failed_initialization("Could not initialize Zephyr library, quitting!")
587588

@@ -594,10 +595,11 @@ def zephyr_load_session_autoretry(session_path: str) -> None:
594595
session = f.read()
595596
zephyr_ctypes.check(zephyr_ctypes.ZInitialize())
596597
zephyr_ctypes.check(zephyr_ctypes.ZLoadSession(session, len(session)))
597-
return
598598
except zephyr_ctypes.ZephyrError:
599599
logger.exception("Error loading saved Zephyr session (retrying). Traceback:")
600600
backoff.fail()
601+
else:
602+
return
601603

602604
quit_failed_initialization("Could not load saved Zephyr session, quitting!")
603605

@@ -620,13 +622,14 @@ def zephyr_subscribe_autoretry(sub: Tuple[str, str, str]) -> None:
620622
0,
621623
)
622624
)
623-
backoff.succeed()
624-
return
625625
except zephyr_ctypes.ZephyrError:
626626
# Probably a SERVNAK from the zephyr server, but log the
627627
# traceback just in case it's something else
628628
logger.exception("Error subscribing to personals (retrying). Traceback:")
629629
backoff.fail()
630+
else:
631+
backoff.succeed()
632+
return
630633

631634
quit_failed_initialization("Could not subscribe to personals, quitting!")
632635

zulip_bots/zulip_bots/bots/converter/converter.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@
1111
def is_float(value: Any) -> bool:
1212
try:
1313
float(value)
14-
return True
1514
except ValueError:
1615
return False
1716

17+
return True
18+
1819

1920
# Rounds the number 'x' to 'digits' significant digits.
2021
# A normal 'round()' would round the number to an absolute amount of

zulip_bots/zulip_bots/bots/trivia_quiz/trivia_quiz.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,11 @@ def handle_message(self, message: Dict[str, Any], bot_handler: BotHandler) -> No
2828
if query == "new":
2929
try:
3030
start_new_quiz(message, bot_handler)
31-
return
3231
except NotAvailableError:
3332
bot_response = "Uh-Oh! Trivia service is down."
3433
bot_handler.send_reply(message, bot_response)
35-
return
34+
35+
return
3636
elif query.startswith("answer"):
3737
try:
3838
(quiz_id, answer) = parse_answer(query)

0 commit comments

Comments
 (0)