cleanup: Remove unused variables.
Generated by autoflake.
MODIFY
zulip/integrations/bridge_with_matrix/matrix_bridge.py
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()

MODIFY
zulip/integrations/jabber/jabber_mirror_backend.py
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)

MODIFY
zulip/integrations/log2zulip/log2zulip
zulip/integrations/log2zulip/log2zulip
@@ -121,5 +121,5 @@ if __name__ == "__main__":
finally:
try:
os.remove(lock_path)
- except OSError as IOError:
+ except OSError:
pass

MODIFY
zulip_bots/zulip_bots/bots/beeminder/test_beeminder.py
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',

MODIFY
zulip_bots/zulip_bots/bots/define/define.py
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&nbsp;&nbsp;{}'.format(d['type'], d['definition'], html2text.html2text(example))
- except Exception as e:
+ except Exception:
response += self.REQUEST_ERROR_MESSAGE
logging.exception("")

MODIFY
zulip_bots/zulip_bots/bots/dialogflow/test_dialogflow.py
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.")

MODIFY
zulip_bots/zulip_bots/bots/giphy/test_giphy.py
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'})

MODIFY
zulip_bots/zulip_bots/bots/merels/libraries/game.py
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

MODIFY
zulip_bots/zulip_bots/bots/youtube/test_youtube.py
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)' \

MODIFY
zulip_bots/zulip_bots/game_handler.py
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)

MODIFY
zulip_bots/zulip_bots/run.py
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()

MODIFY
zulip_bots/zulip_bots/tests/test_lib.py
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,

MODIFY
zulip_botserver/zulip_botserver/server.py
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"

cleanup: Remove unused variables.

Generated by autoflake.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>