ruff: Fix SIM105 Use contextlib.suppress
instead of try
-except
-pass
.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
6a4ad8861b
commit
2aa36f90fb
2 changed files with 7 additions and 11 deletions
|
@ -121,15 +121,13 @@ class JabberToZulipBot(ClientXMPP):
|
|||
|
||||
# Configure the room. Really, we should only do this if the room is
|
||||
# newly created.
|
||||
form = None
|
||||
try:
|
||||
form = xep0045.getRoomConfig(muc_jid)
|
||||
except ValueError:
|
||||
pass
|
||||
if form:
|
||||
xep0045.configureRoom(muc_jid, form)
|
||||
else:
|
||||
logging.error("Could not configure room: %s", muc_jid)
|
||||
return
|
||||
|
||||
xep0045.configureRoom(muc_jid, form)
|
||||
|
||||
def leave_muc(self, room: str) -> None:
|
||||
if room not in self.rooms:
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import argparse
|
||||
import contextlib
|
||||
import errno
|
||||
import json
|
||||
import os
|
||||
import platform
|
||||
import re
|
||||
|
@ -9,6 +11,7 @@ import subprocess
|
|||
import sys
|
||||
import tempfile
|
||||
import traceback
|
||||
from typing import List
|
||||
|
||||
# Use the Zulip virtualenv if available
|
||||
sys.path.append("/home/zulip/deployments/current")
|
||||
|
@ -24,10 +27,7 @@ except ImportError:
|
|||
except ImportError:
|
||||
pass
|
||||
|
||||
import json
|
||||
|
||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "../../"))
|
||||
from typing import List
|
||||
|
||||
import zulip
|
||||
|
||||
|
@ -129,7 +129,5 @@ if __name__ == "__main__":
|
|||
sys.exit(1)
|
||||
process_logs()
|
||||
finally:
|
||||
try:
|
||||
with contextlib.suppress(OSError):
|
||||
os.remove(lock_path)
|
||||
except OSError:
|
||||
pass
|
||||
|
|
Loading…
Add table
Reference in a new issue