Skip to content

Commit 88ab78e

Browse files
committed
ruff: Fix RSE102 Unnecessary parentheses on raised exception.
Signed-off-by: Anders Kaseorg <[email protected]>
1 parent 63246e4 commit 88ab78e

File tree

7 files changed

+17
-17
lines changed

7 files changed

+17
-17
lines changed

zulip_bots/zulip_bots/bots/giphy/giphy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def get_url_gif_giphy(keyword: str, api_key: str) -> Union[int, str]:
7777
try:
7878
gif_url = data.json()["data"]["images"]["original"]["url"]
7979
except (TypeError, KeyError): # Usually triggered by no result in Giphy.
80-
raise GiphyNoResultException()
80+
raise GiphyNoResultException
8181
return gif_url
8282

8383

zulip_bots/zulip_bots/bots/idonethis/idonethis.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ def make_API_request(
4949
and r.json()["error"] == "Invalid API Authentication"
5050
):
5151
logging.error("Error authenticating, please check key " + str(r.url))
52-
raise AuthenticationException()
52+
raise AuthenticationException
5353
else:
5454
logging.error("Error make API request, code " + str(r.status_code) + ". json: " + r.json())
55-
raise UnspecifiedProblemException()
55+
raise UnspecifiedProblemException
5656

5757

5858
def api_noop() -> None:

zulip_bots/zulip_bots/bots/incident/incident.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def start_new_incident(query: str, message: Dict[str, Any], bot_handler: BotHand
6363
def parse_answer(query: str) -> Tuple[str, str]:
6464
m = re.match(r"answer\s+(TICKET....)\s+(.)", query)
6565
if not m:
66-
raise InvalidAnswerException()
66+
raise InvalidAnswerException
6767

6868
ticket_id = m.group(1)
6969

@@ -74,7 +74,7 @@ def parse_answer(query: str) -> Tuple[str, str]:
7474

7575
answer = m.group(2).upper()
7676
if answer not in "1234":
77-
raise InvalidAnswerException()
77+
raise InvalidAnswerException
7878

7979
return (ticket_id, ANSWERS[answer])
8080

zulip_bots/zulip_bots/bots/mention/mention.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,13 @@ def generate_response(self, keyword: str) -> str:
116116
alert_id = self.get_alert_id(keyword)
117117
except (TypeError, KeyError):
118118
# Usually triggered by invalid token or json parse error when account quote is finished.
119-
raise MentionNoResponseException()
119+
raise MentionNoResponseException
120120

121121
try:
122122
mentions = self.get_mentions(alert_id)
123123
except (TypeError, KeyError):
124124
# Usually triggered by no response or json parse error when account quota is finished.
125-
raise MentionNoResponseException()
125+
raise MentionNoResponseException
126126

127127
reply = "The most recent mentions of `" + keyword + "` on the web are: \n"
128128
for mention in mentions:

zulip_bots/zulip_bots/bots/trivia_quiz/trivia_quiz.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,12 @@ def start_new_quiz(message: Dict[str, Any], bot_handler: BotHandler) -> None:
7575
def parse_answer(query: str) -> Tuple[str, str]:
7676
m = re.match(r"answer\s+(Q...)\s+(.)", query)
7777
if not m:
78-
raise InvalidAnswerException()
78+
raise InvalidAnswerException
7979

8080
quiz_id = m.group(1)
8181
answer = m.group(2).upper()
8282
if answer not in "ABCD":
83-
raise InvalidAnswerException()
83+
raise InvalidAnswerException
8484

8585
return (quiz_id, answer)
8686

@@ -98,10 +98,10 @@ def get_trivia_payload() -> Dict[str, Any]:
9898
data = requests.get(url)
9999

100100
except requests.exceptions.RequestException:
101-
raise NotAvailableException()
101+
raise NotAvailableException
102102

103103
if data.status_code != 200:
104-
raise NotAvailableException()
104+
raise NotAvailableException
105105

106106
payload = data.json()
107107
return payload

zulip_bots/zulip_bots/bots/xkcd/xkcd.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def fetch_xkcd_query(mode: int, comic_id: Optional[str] = None) -> Dict[str, str
104104
latest = requests.get(LATEST_XKCD_URL)
105105

106106
if latest.status_code != 200:
107-
raise XkcdServerError()
107+
raise XkcdServerError
108108

109109
latest_id = latest.json()["num"]
110110
random_id = random.randint(1, latest_id)
@@ -118,9 +118,9 @@ def fetch_xkcd_query(mode: int, comic_id: Optional[str] = None) -> Dict[str, str
118118
fetched = requests.get(url)
119119

120120
if fetched.status_code == 404:
121-
raise XkcdNotFoundError()
121+
raise XkcdNotFoundError
122122
elif fetched.status_code != 200:
123-
raise XkcdServerError()
123+
raise XkcdServerError
124124

125125
xkcd_json = fetched.json()
126126
except requests.exceptions.ConnectionError:

zulip_bots/zulip_bots/test_lib.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class BotQuitException(Exception):
5151
pass
5252

5353
def quit(self, message: str = "") -> None:
54-
raise self.BotQuitException()
54+
raise self.BotQuitException
5555

5656
def get_config_info(self, bot_name: str, optional: bool = False) -> Dict[str, str]:
5757
return {}
@@ -77,10 +77,10 @@ class DefaultTests:
7777
bot_name = ""
7878

7979
def make_request_message(self, content: str) -> Dict[str, Any]:
80-
raise NotImplementedError()
80+
raise NotImplementedError
8181

8282
def get_response(self, message: Dict[str, Any]) -> Dict[str, Any]:
83-
raise NotImplementedError()
83+
raise NotImplementedError
8484

8585
def test_bot_usage(self) -> None:
8686
bot = get_bot_message_handler(self.bot_name)

0 commit comments

Comments
 (0)