diff --git a/zulip_bots/zulip_bots/bots/giphy/giphy.py b/zulip_bots/zulip_bots/bots/giphy/giphy.py index d0e0c73e..f5eb3599 100644 --- a/zulip_bots/zulip_bots/bots/giphy/giphy.py +++ b/zulip_bots/zulip_bots/bots/giphy/giphy.py @@ -77,7 +77,7 @@ def get_url_gif_giphy(keyword: str, api_key: str) -> Union[int, str]: try: gif_url = data.json()["data"]["images"]["original"]["url"] except (TypeError, KeyError): # Usually triggered by no result in Giphy. - raise GiphyNoResultException() + raise GiphyNoResultException return gif_url diff --git a/zulip_bots/zulip_bots/bots/idonethis/idonethis.py b/zulip_bots/zulip_bots/bots/idonethis/idonethis.py index 443841a6..7163c637 100644 --- a/zulip_bots/zulip_bots/bots/idonethis/idonethis.py +++ b/zulip_bots/zulip_bots/bots/idonethis/idonethis.py @@ -49,10 +49,10 @@ def make_API_request( and r.json()["error"] == "Invalid API Authentication" ): logging.error("Error authenticating, please check key " + str(r.url)) - raise AuthenticationException() + raise AuthenticationException else: logging.error("Error make API request, code " + str(r.status_code) + ". json: " + r.json()) - raise UnspecifiedProblemException() + raise UnspecifiedProblemException def api_noop() -> None: diff --git a/zulip_bots/zulip_bots/bots/incident/incident.py b/zulip_bots/zulip_bots/bots/incident/incident.py index 6ff1ab05..66dca582 100644 --- a/zulip_bots/zulip_bots/bots/incident/incident.py +++ b/zulip_bots/zulip_bots/bots/incident/incident.py @@ -63,7 +63,7 @@ def start_new_incident(query: str, message: Dict[str, Any], bot_handler: BotHand def parse_answer(query: str) -> Tuple[str, str]: m = re.match(r"answer\s+(TICKET....)\s+(.)", query) if not m: - raise InvalidAnswerException() + raise InvalidAnswerException ticket_id = m.group(1) @@ -74,7 +74,7 @@ def parse_answer(query: str) -> Tuple[str, str]: answer = m.group(2).upper() if answer not in "1234": - raise InvalidAnswerException() + raise InvalidAnswerException return (ticket_id, ANSWERS[answer]) diff --git a/zulip_bots/zulip_bots/bots/mention/mention.py b/zulip_bots/zulip_bots/bots/mention/mention.py index 3935f4db..98668d17 100644 --- a/zulip_bots/zulip_bots/bots/mention/mention.py +++ b/zulip_bots/zulip_bots/bots/mention/mention.py @@ -116,13 +116,13 @@ class MentionHandler: alert_id = self.get_alert_id(keyword) except (TypeError, KeyError): # Usually triggered by invalid token or json parse error when account quote is finished. - raise MentionNoResponseException() + raise MentionNoResponseException try: mentions = self.get_mentions(alert_id) except (TypeError, KeyError): # Usually triggered by no response or json parse error when account quota is finished. - raise MentionNoResponseException() + raise MentionNoResponseException reply = "The most recent mentions of `" + keyword + "` on the web are: \n" for mention in mentions: diff --git a/zulip_bots/zulip_bots/bots/trivia_quiz/trivia_quiz.py b/zulip_bots/zulip_bots/bots/trivia_quiz/trivia_quiz.py index ebb8b9b2..8fb4463b 100644 --- a/zulip_bots/zulip_bots/bots/trivia_quiz/trivia_quiz.py +++ b/zulip_bots/zulip_bots/bots/trivia_quiz/trivia_quiz.py @@ -75,12 +75,12 @@ def start_new_quiz(message: Dict[str, Any], bot_handler: BotHandler) -> None: def parse_answer(query: str) -> Tuple[str, str]: m = re.match(r"answer\s+(Q...)\s+(.)", query) if not m: - raise InvalidAnswerException() + raise InvalidAnswerException quiz_id = m.group(1) answer = m.group(2).upper() if answer not in "ABCD": - raise InvalidAnswerException() + raise InvalidAnswerException return (quiz_id, answer) @@ -98,10 +98,10 @@ def get_trivia_payload() -> Dict[str, Any]: data = requests.get(url) except requests.exceptions.RequestException: - raise NotAvailableException() + raise NotAvailableException if data.status_code != 200: - raise NotAvailableException() + raise NotAvailableException payload = data.json() return payload diff --git a/zulip_bots/zulip_bots/bots/xkcd/xkcd.py b/zulip_bots/zulip_bots/bots/xkcd/xkcd.py index 09cd44ab..fd92f608 100644 --- a/zulip_bots/zulip_bots/bots/xkcd/xkcd.py +++ b/zulip_bots/zulip_bots/bots/xkcd/xkcd.py @@ -104,7 +104,7 @@ def fetch_xkcd_query(mode: int, comic_id: Optional[str] = None) -> Dict[str, str latest = requests.get(LATEST_XKCD_URL) if latest.status_code != 200: - raise XkcdServerError() + raise XkcdServerError latest_id = latest.json()["num"] 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 fetched = requests.get(url) if fetched.status_code == 404: - raise XkcdNotFoundError() + raise XkcdNotFoundError elif fetched.status_code != 200: - raise XkcdServerError() + raise XkcdServerError xkcd_json = fetched.json() except requests.exceptions.ConnectionError: diff --git a/zulip_bots/zulip_bots/test_lib.py b/zulip_bots/zulip_bots/test_lib.py index a03cf0fe..58a8228a 100755 --- a/zulip_bots/zulip_bots/test_lib.py +++ b/zulip_bots/zulip_bots/test_lib.py @@ -51,7 +51,7 @@ class StubBotHandler: pass def quit(self, message: str = "") -> None: - raise self.BotQuitException() + raise self.BotQuitException def get_config_info(self, bot_name: str, optional: bool = False) -> Dict[str, str]: return {} @@ -77,10 +77,10 @@ class DefaultTests: bot_name = "" def make_request_message(self, content: str) -> Dict[str, Any]: - raise NotImplementedError() + raise NotImplementedError def get_response(self, message: Dict[str, Any]) -> Dict[str, Any]: - raise NotImplementedError() + raise NotImplementedError def test_bot_usage(self) -> None: bot = get_bot_message_handler(self.bot_name)