Skip to content

Commit 2aa36f9

Browse files
committed
ruff: Fix SIM105 Use contextlib.suppress instead of try-except-pass.
Signed-off-by: Anders Kaseorg <[email protected]>
1 parent 6a4ad88 commit 2aa36f9

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

zulip/integrations/jabber/jabber_mirror_backend.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,13 @@ def join_muc(self, room: str) -> None:
121121

122122
# Configure the room. Really, we should only do this if the room is
123123
# newly created.
124-
form = None
125124
try:
126125
form = xep0045.getRoomConfig(muc_jid)
127126
except ValueError:
128-
pass
129-
if form:
130-
xep0045.configureRoom(muc_jid, form)
131-
else:
132127
logging.error("Could not configure room: %s", muc_jid)
128+
return
129+
130+
xep0045.configureRoom(muc_jid, form)
133131

134132
def leave_muc(self, room: str) -> None:
135133
if room not in self.rooms:

zulip/integrations/log2zulip/log2zulip

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
#!/usr/bin/env python3
22

33
import argparse
4+
import contextlib
45
import errno
6+
import json
57
import os
68
import platform
79
import re
810
import subprocess
911
import sys
1012
import tempfile
1113
import traceback
14+
from typing import List
1215

1316
# Use the Zulip virtualenv if available
1417
sys.path.append("/home/zulip/deployments/current")
@@ -24,10 +27,7 @@ except ImportError:
2427
except ImportError:
2528
pass
2629

27-
import json
28-
2930
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "../../"))
30-
from typing import List
3131

3232
import zulip
3333

@@ -129,7 +129,5 @@ if __name__ == "__main__":
129129
sys.exit(1)
130130
process_logs()
131131
finally:
132-
try:
132+
with contextlib.suppress(OSError):
133133
os.remove(lock_path)
134-
except OSError:
135-
pass

0 commit comments

Comments
 (0)