diff --git a/zulip/integrations/bridge_with_matrix/matrix_bridge.py b/zulip/integrations/bridge_with_matrix/matrix_bridge.py index 4ddee2d..6897dd5 100644 --- a/zulip/integrations/bridge_with_matrix/matrix_bridge.py +++ b/zulip/integrations/bridge_with_matrix/matrix_bridge.py @@ -43,7 +43,7 @@ def matrix_login(matrix_client: Any, matrix_config: Dict[str, Any]) -> None: raise Bridge_FatalMatrixException("Bad username or password.") else: raise Bridge_FatalMatrixException("Check if your server details are correct.") - except MissingSchema as exception: + except MissingSchema: raise Bridge_FatalMatrixException("Bad URL format.") def matrix_join_room(matrix_client: Any, matrix_config: Dict[str, Any]) -> Any: @@ -304,7 +304,7 @@ def main() -> None: sys.exit("Zulip bridge error: {}".format(exception)) except zulip.ZulipError as exception: sys.exit("Zulip error: {}".format(exception)) - except Exception as e: + except Exception: traceback.print_exc() backoff.fail() diff --git a/zulip/integrations/jabber/jabber_mirror_backend.py b/zulip/integrations/jabber/jabber_mirror_backend.py index 88bc988..8fa56f8 100755 --- a/zulip/integrations/jabber/jabber_mirror_backend.py +++ b/zulip/integrations/jabber/jabber_mirror_backend.py @@ -451,7 +451,7 @@ option does not affect login credentials.'''.replace("\n", " ")) logging.info("Connecting to Zulip.") zulipToJabber.client.call_on_each_event(zulipToJabber.process_event, event_types=event_types) - except BaseException as e: + except BaseException: logging.exception("Exception in main loop") xmpp.abort() sys.exit(1) diff --git a/zulip/integrations/log2zulip/log2zulip b/zulip/integrations/log2zulip/log2zulip index 0c2e8c2..318430f 100755 --- a/zulip/integrations/log2zulip/log2zulip +++ b/zulip/integrations/log2zulip/log2zulip @@ -121,5 +121,5 @@ if __name__ == "__main__": finally: try: os.remove(lock_path) - except OSError as IOError: + except OSError: pass diff --git a/zulip_bots/zulip_bots/bots/beeminder/test_beeminder.py b/zulip_bots/zulip_bots/bots/beeminder/test_beeminder.py index aedc53b..c2ac3cd 100644 --- a/zulip_bots/zulip_bots/bots/beeminder/test_beeminder.py +++ b/zulip_bots/zulip_bots/bots/beeminder/test_beeminder.py @@ -67,8 +67,8 @@ at syntax by: @mention-botname help" right now.\nPlease try again later') def test_invalid_when_handle_message(self) -> None: - bot = get_bot_message_handler(self.bot_name) - bot_handler = StubBotHandler() + get_bot_message_handler(self.bot_name) + StubBotHandler() with self.mock_config_info({'auth_token': 'someInvalidKey', 'username': 'aaron', diff --git a/zulip_bots/zulip_bots/bots/define/define.py b/zulip_bots/zulip_bots/bots/define/define.py index d3e9f27..3b0c534 100644 --- a/zulip_bots/zulip_bots/bots/define/define.py +++ b/zulip_bots/zulip_bots/bots/define/define.py @@ -65,7 +65,7 @@ class DefineHandler: example = d['example'] if d['example'] else '*No example available.*' response += '\n' + '* (**{}**) {}\n  {}'.format(d['type'], d['definition'], html2text.html2text(example)) - except Exception as e: + except Exception: response += self.REQUEST_ERROR_MESSAGE logging.exception("") diff --git a/zulip_bots/zulip_bots/bots/dialogflow/test_dialogflow.py b/zulip_bots/zulip_bots/bots/dialogflow/test_dialogflow.py index 560a4b0..c27e44b 100644 --- a/zulip_bots/zulip_bots/bots/dialogflow/test_dialogflow.py +++ b/zulip_bots/zulip_bots/bots/dialogflow/test_dialogflow.py @@ -28,7 +28,7 @@ class MockTextRequest(): def mock_dialogflow(test_name: str, bot_name: str) -> Iterator[None]: response_data = read_bot_fixture_data(bot_name, test_name) try: - df_request = response_data['request'] + response_data['request'] df_response = response_data['response'] except KeyError: print("ERROR: 'request' or 'response' field not found in fixture.") diff --git a/zulip_bots/zulip_bots/bots/giphy/test_giphy.py b/zulip_bots/zulip_bots/bots/giphy/test_giphy.py index 8bf6eb4..3349150 100755 --- a/zulip_bots/zulip_bots/bots/giphy/test_giphy.py +++ b/zulip_bots/zulip_bots/bots/giphy/test_giphy.py @@ -33,8 +33,8 @@ class TestGiphyBot(BotTestCase, DefaultTests): ) def test_invalid_config(self) -> None: - bot = get_bot_message_handler(self.bot_name) - bot_handler = StubBotHandler() + get_bot_message_handler(self.bot_name) + StubBotHandler() with self.mock_http_conversation('test_403'): self.validate_invalid_config({'key': '12345678'}, "This is likely due to an invalid key.\n") @@ -45,8 +45,8 @@ class TestGiphyBot(BotTestCase, DefaultTests): self.validate_invalid_config({'key': '12345678'}, str(error)) def test_valid_config(self) -> None: - bot = get_bot_message_handler(self.bot_name) - bot_handler = StubBotHandler() + get_bot_message_handler(self.bot_name) + StubBotHandler() with self.mock_http_conversation('test_normal'): self.validate_valid_config({'key': '12345678'}) diff --git a/zulip_bots/zulip_bots/bots/merels/libraries/game.py b/zulip_bots/zulip_bots/bots/merels/libraries/game.py index 3190f91..61f1fd4 100644 --- a/zulip_bots/zulip_bots/bots/merels/libraries/game.py +++ b/zulip_bots/zulip_bots/bots/merels/libraries/game.py @@ -54,7 +54,7 @@ def beat(message, topic_name, merels_storage): we want to keep the turn of the same played, an empty string otherwise. """ - merels = database.MerelsStorage(topic_name, merels_storage) + database.MerelsStorage(topic_name, merels_storage) match = COMMAND_PATTERN.match(message) same_player_move = "" # message indicating move of the same player diff --git a/zulip_bots/zulip_bots/bots/youtube/test_youtube.py b/zulip_bots/zulip_bots/bots/youtube/test_youtube.py index d527fc2..14d701c 100644 --- a/zulip_bots/zulip_bots/bots/youtube/test_youtube.py +++ b/zulip_bots/zulip_bots/bots/youtube/test_youtube.py @@ -53,8 +53,8 @@ class TestYoutubeBot(BotTestCase, DefaultTests): bot.initialize(bot_handler) def test_multiple(self) -> None: - bot = get_bot_message_handler(self.bot_name) - bot_handler = StubBotHandler() + get_bot_message_handler(self.bot_name) + StubBotHandler() bot_response = 'Here is what I found for `marvel` : ' \ '\n * Marvel Studios\' Avengers: Infinity War Official Trailer - [Watch now](https://www.youtube.com/watch/6ZfuNTqbHE8)' \ diff --git a/zulip_bots/zulip_bots/game_handler.py b/zulip_bots/zulip_bots/game_handler.py index 5d6b049..4e89d0d 100644 --- a/zulip_bots/zulip_bots/game_handler.py +++ b/zulip_bots/zulip_bots/game_handler.py @@ -637,7 +637,7 @@ To move subjects, send your message again, otherwise join the game using the lin def get_user_cache(self) -> Dict[str, Any]: try: user_cache_str = self.bot_handler.storage.get('users') - except KeyError as e: + except KeyError: return {} self.user_cache = json.loads(user_cache_str) return self.user_cache @@ -850,7 +850,7 @@ class GameInstance: def make_move(self, content: str, is_computer: bool) -> None: try: - board = self.model.make_move(content, self.turn, is_computer) + self.model.make_move(content, self.turn, is_computer) # Keep the turn of the same player except SamePlayerMove as smp: self.same_player_turn(content, smp.message, is_computer) diff --git a/zulip_bots/zulip_bots/run.py b/zulip_bots/zulip_bots/run.py index ed4b721..0002bce 100755 --- a/zulip_bots/zulip_bots/run.py +++ b/zulip_bots/zulip_bots/run.py @@ -111,7 +111,7 @@ def main() -> None: try: lib_module = finder.import_module_from_source(bot_path, bot_name) - except ImportError as e: + except ImportError: req_path = os.path.join(os.path.dirname(bot_path), "requirements.txt") with open(req_path) as fp: deps_list = fp.read() diff --git a/zulip_bots/zulip_bots/tests/test_lib.py b/zulip_bots/zulip_bots/tests/test_lib.py index dbf882e..2c93903 100644 --- a/zulip_bots/zulip_bots/tests/test_lib.py +++ b/zulip_bots/zulip_bots/tests/test_lib.py @@ -132,7 +132,7 @@ class LibTest(TestCase): def test_content_and_full_content(self): client = FakeClient() - profile = client.get_profile() + client.get_profile() handler = ExternalBotHandler( client=client, root_dir=None, diff --git a/zulip_botserver/zulip_botserver/server.py b/zulip_botserver/zulip_botserver/server.py index 33e2667..ce7aa4d 100644 --- a/zulip_botserver/zulip_botserver/server.py +++ b/zulip_botserver/zulip_botserver/server.py @@ -155,7 +155,7 @@ def handle_bot() -> str: raise Unauthorized("Request token does not match token found for bot {} in the " "Botserver configuration file. Do the outgoing webhooks in " "Zulip point to the right Botserver?".format(event['bot_email'])) - lib_module = app.config.get("BOTS_LIB_MODULES", {})[bot] + app.config.get("BOTS_LIB_MODULES", {})[bot] bot_handler = app.config.get("BOT_HANDLERS", {})[bot] message_handler = app.config.get("MESSAGE_HANDLERS", {})[bot] is_mentioned = event['trigger'] == "mention"