cleanup: Remove unused variables.

Generated by autoflake.

Signed-off-by: Anders Kaseorg <anders@zulipchat.com>
This commit is contained in:
Anders Kaseorg 2020-04-18 16:36:24 -07:00 committed by Tim Abbott
parent f5d96dbcce
commit 54b2578204
13 changed files with 20 additions and 20 deletions

View file

@ -43,7 +43,7 @@ def matrix_login(matrix_client: Any, matrix_config: Dict[str, Any]) -> None:
raise Bridge_FatalMatrixException("Bad username or password.") raise Bridge_FatalMatrixException("Bad username or password.")
else: else:
raise Bridge_FatalMatrixException("Check if your server details are correct.") raise Bridge_FatalMatrixException("Check if your server details are correct.")
except MissingSchema as exception: except MissingSchema:
raise Bridge_FatalMatrixException("Bad URL format.") raise Bridge_FatalMatrixException("Bad URL format.")
def matrix_join_room(matrix_client: Any, matrix_config: Dict[str, Any]) -> Any: 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)) sys.exit("Zulip bridge error: {}".format(exception))
except zulip.ZulipError as exception: except zulip.ZulipError as exception:
sys.exit("Zulip error: {}".format(exception)) sys.exit("Zulip error: {}".format(exception))
except Exception as e: except Exception:
traceback.print_exc() traceback.print_exc()
backoff.fail() backoff.fail()

View file

@ -451,7 +451,7 @@ option does not affect login credentials.'''.replace("\n", " "))
logging.info("Connecting to Zulip.") logging.info("Connecting to Zulip.")
zulipToJabber.client.call_on_each_event(zulipToJabber.process_event, zulipToJabber.client.call_on_each_event(zulipToJabber.process_event,
event_types=event_types) event_types=event_types)
except BaseException as e: except BaseException:
logging.exception("Exception in main loop") logging.exception("Exception in main loop")
xmpp.abort() xmpp.abort()
sys.exit(1) sys.exit(1)

View file

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

View file

@ -67,8 +67,8 @@ at syntax by: @mention-botname help"
right now.\nPlease try again later') right now.\nPlease try again later')
def test_invalid_when_handle_message(self) -> None: def test_invalid_when_handle_message(self) -> None:
bot = get_bot_message_handler(self.bot_name) get_bot_message_handler(self.bot_name)
bot_handler = StubBotHandler() StubBotHandler()
with self.mock_config_info({'auth_token': 'someInvalidKey', with self.mock_config_info({'auth_token': 'someInvalidKey',
'username': 'aaron', 'username': 'aaron',

View file

@ -65,7 +65,7 @@ class DefineHandler:
example = d['example'] if d['example'] else '*No example available.*' example = d['example'] if d['example'] else '*No example available.*'
response += '\n' + '* (**{}**) {}\n&nbsp;&nbsp;{}'.format(d['type'], d['definition'], html2text.html2text(example)) response += '\n' + '* (**{}**) {}\n&nbsp;&nbsp;{}'.format(d['type'], d['definition'], html2text.html2text(example))
except Exception as e: except Exception:
response += self.REQUEST_ERROR_MESSAGE response += self.REQUEST_ERROR_MESSAGE
logging.exception("") logging.exception("")

View file

@ -28,7 +28,7 @@ class MockTextRequest():
def mock_dialogflow(test_name: str, bot_name: str) -> Iterator[None]: def mock_dialogflow(test_name: str, bot_name: str) -> Iterator[None]:
response_data = read_bot_fixture_data(bot_name, test_name) response_data = read_bot_fixture_data(bot_name, test_name)
try: try:
df_request = response_data['request'] response_data['request']
df_response = response_data['response'] df_response = response_data['response']
except KeyError: except KeyError:
print("ERROR: 'request' or 'response' field not found in fixture.") print("ERROR: 'request' or 'response' field not found in fixture.")

View file

@ -33,8 +33,8 @@ class TestGiphyBot(BotTestCase, DefaultTests):
) )
def test_invalid_config(self) -> None: def test_invalid_config(self) -> None:
bot = get_bot_message_handler(self.bot_name) get_bot_message_handler(self.bot_name)
bot_handler = StubBotHandler() StubBotHandler()
with self.mock_http_conversation('test_403'): with self.mock_http_conversation('test_403'):
self.validate_invalid_config({'key': '12345678'}, self.validate_invalid_config({'key': '12345678'},
"This is likely due to an invalid key.\n") "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)) self.validate_invalid_config({'key': '12345678'}, str(error))
def test_valid_config(self) -> None: def test_valid_config(self) -> None:
bot = get_bot_message_handler(self.bot_name) get_bot_message_handler(self.bot_name)
bot_handler = StubBotHandler() StubBotHandler()
with self.mock_http_conversation('test_normal'): with self.mock_http_conversation('test_normal'):
self.validate_valid_config({'key': '12345678'}) self.validate_valid_config({'key': '12345678'})

View file

@ -54,7 +54,7 @@ def beat(message, topic_name, merels_storage):
we want to keep the turn of the same played, we want to keep the turn of the same played,
an empty string otherwise. an empty string otherwise.
""" """
merels = database.MerelsStorage(topic_name, merels_storage) database.MerelsStorage(topic_name, merels_storage)
match = COMMAND_PATTERN.match(message) match = COMMAND_PATTERN.match(message)
same_player_move = "" # message indicating move of the same player same_player_move = "" # message indicating move of the same player

View file

@ -53,8 +53,8 @@ class TestYoutubeBot(BotTestCase, DefaultTests):
bot.initialize(bot_handler) bot.initialize(bot_handler)
def test_multiple(self) -> None: def test_multiple(self) -> None:
bot = get_bot_message_handler(self.bot_name) get_bot_message_handler(self.bot_name)
bot_handler = StubBotHandler() StubBotHandler()
bot_response = 'Here is what I found for `marvel` : ' \ 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)' \ '\n * Marvel Studios\' Avengers: Infinity War Official Trailer - [Watch now](https://www.youtube.com/watch/6ZfuNTqbHE8)' \

View file

@ -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]: def get_user_cache(self) -> Dict[str, Any]:
try: try:
user_cache_str = self.bot_handler.storage.get('users') user_cache_str = self.bot_handler.storage.get('users')
except KeyError as e: except KeyError:
return {} return {}
self.user_cache = json.loads(user_cache_str) self.user_cache = json.loads(user_cache_str)
return self.user_cache return self.user_cache
@ -850,7 +850,7 @@ class GameInstance:
def make_move(self, content: str, is_computer: bool) -> None: def make_move(self, content: str, is_computer: bool) -> None:
try: 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 # Keep the turn of the same player
except SamePlayerMove as smp: except SamePlayerMove as smp:
self.same_player_turn(content, smp.message, is_computer) self.same_player_turn(content, smp.message, is_computer)

View file

@ -111,7 +111,7 @@ def main() -> None:
try: try:
lib_module = finder.import_module_from_source(bot_path, bot_name) 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") req_path = os.path.join(os.path.dirname(bot_path), "requirements.txt")
with open(req_path) as fp: with open(req_path) as fp:
deps_list = fp.read() deps_list = fp.read()

View file

@ -132,7 +132,7 @@ class LibTest(TestCase):
def test_content_and_full_content(self): def test_content_and_full_content(self):
client = FakeClient() client = FakeClient()
profile = client.get_profile() client.get_profile()
handler = ExternalBotHandler( handler = ExternalBotHandler(
client=client, client=client,
root_dir=None, root_dir=None,

View file

@ -155,7 +155,7 @@ def handle_bot() -> str:
raise Unauthorized("Request token does not match token found for bot {} in the " raise Unauthorized("Request token does not match token found for bot {} in the "
"Botserver configuration file. Do the outgoing webhooks in " "Botserver configuration file. Do the outgoing webhooks in "
"Zulip point to the right Botserver?".format(event['bot_email'])) "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] bot_handler = app.config.get("BOT_HANDLERS", {})[bot]
message_handler = app.config.get("MESSAGE_HANDLERS", {})[bot] message_handler = app.config.get("MESSAGE_HANDLERS", {})[bot]
is_mentioned = event['trigger'] == "mention" is_mentioned = event['trigger'] == "mention"