diff --git a/zulip_bots/zulip_bots/bots/followup/followup.py b/zulip_bots/zulip_bots/bots/followup/followup.py index db95d75..95eeb57 100644 --- a/zulip_bots/zulip_bots/bots/followup/followup.py +++ b/zulip_bots/zulip_bots/bots/followup/followup.py @@ -13,7 +13,7 @@ class FollowupHandler(object): external issue tracker as well. ''' - def usage(self: Any) -> str: + def usage(self) -> str: return ''' This plugin will allow users to flag messages as being follow-up items. Users should preface @@ -23,7 +23,7 @@ class FollowupHandler(object): called "followup" that your API user can send to. ''' - def handle_message(self: Any, message: Dict[str, str], bot_handler: Any) -> None: + def handle_message(self, message: Dict[str, str], bot_handler: Any) -> None: if message['content'] == '': bot_response = "Please specify the message you want to send to followup stream after @mention-bot" bot_handler.send_reply(message, bot_response) @@ -36,7 +36,7 @@ class FollowupHandler(object): content=bot_response, )) - def get_bot_followup_response(self: Any, message: Dict[str, str]) -> str: + def get_bot_followup_response(self, message: Dict[str, str]) -> str: original_content = message['content'] original_sender = message['sender_email'] temp_content = 'from %s: ' % (original_sender,) diff --git a/zulip_bots/zulip_bots/bots/followup/test_followup.py b/zulip_bots/zulip_bots/bots/followup/test_followup.py index 600488b..599bf92 100755 --- a/zulip_bots/zulip_bots/bots/followup/test_followup.py +++ b/zulip_bots/zulip_bots/bots/followup/test_followup.py @@ -10,7 +10,7 @@ from typing import Any class TestFollowUpBot(BotTestCase): bot_name = "followup" - def test_bot(self: Any) -> None: + def test_bot(self) -> None: expected_send_reply = [ ("", 'Please specify the message you want to send to followup stream after @mention-bot') ] diff --git a/zulip_bots/zulip_bots/bots/giphy/giphy.py b/zulip_bots/zulip_bots/bots/giphy/giphy.py index e2a68aa..3f6b887 100644 --- a/zulip_bots/zulip_bots/bots/giphy/giphy.py +++ b/zulip_bots/zulip_bots/bots/giphy/giphy.py @@ -21,17 +21,17 @@ class GiphyHandler(object): and responds with a message with the GIF based on provided keywords. It also responds to private messages. ''' - def usage(self: Any) -> str: + def usage(self) -> str: return ''' This plugin allows users to post GIFs provided by Giphy. Users should preface keywords with the Giphy-bot @mention. The bot responds also to private messages. ''' - def initialize(self: Any, bot_handler: Any) -> None: + def initialize(self, bot_handler: Any) -> None: self.config_info = bot_handler.get_config_info('giphy') - def handle_message(self: Any, message: Dict[str, str], bot_handler: Any) -> None: + def handle_message(self, message: Dict[str, str], bot_handler: Any) -> None: bot_response = get_bot_giphy_response( message, bot_handler, diff --git a/zulip_bots/zulip_bots/bots/giphy/test_giphy.py b/zulip_bots/zulip_bots/bots/giphy/test_giphy.py index b22f19c..a6c34ff 100755 --- a/zulip_bots/zulip_bots/bots/giphy/test_giphy.py +++ b/zulip_bots/zulip_bots/bots/giphy/test_giphy.py @@ -9,7 +9,7 @@ from zulip_bots.test_lib import StubBotHandler, StubBotTestCase, get_bot_message class TestGiphyBot(StubBotTestCase): bot_name = "giphy" - def test_normal(self: Any) -> None: + def test_normal(self) -> None: bot_response = '[Click to enlarge]' \ '(https://media4.giphy.com/media/3o6ZtpxSZbQRRnwCKQ/giphy.gif)' \ '[](/static/images/interactive-bot/giphy/powered-by-giphy.png)' @@ -18,7 +18,7 @@ class TestGiphyBot(StubBotTestCase): self.mock_http_conversation('test_normal'): self.verify_reply('Hello', bot_response) - def test_no_result(self: Any) -> None: + def test_no_result(self) -> None: with self.mock_config_info({'key': '12345678'}), \ self.mock_http_conversation('test_no_result'): self.verify_reply( @@ -26,7 +26,7 @@ class TestGiphyBot(StubBotTestCase): 'Sorry, I don\'t have a GIF for "world without zulip"! :astonished:', ) - def test_403(self: Any) -> None: + def test_403(self) -> None: bot = get_bot_message_handler(self.bot_name) bot_handler = StubBotHandler() @@ -42,7 +42,7 @@ class TestGiphyBot(StubBotTestCase): # but an exception. bot.handle_message(mock_message, bot_handler) - def test_connection_error(self: Any) -> None: + def test_connection_error(self) -> None: with self.mock_config_info({'key': '12345678'}), \ patch('requests.get', side_effect=ConnectionError()), \ patch('logging.warning'): diff --git a/zulip_bots/zulip_bots/bots/github_detail/github_detail.py b/zulip_bots/zulip_bots/bots/github_detail/github_detail.py index 40b30cf..e304866 100644 --- a/zulip_bots/zulip_bots/bots/github_detail/github_detail.py +++ b/zulip_bots/zulip_bots/bots/github_detail/github_detail.py @@ -17,19 +17,19 @@ class GithubHandler(object): GITHUB_ISSUE_URL_TEMPLATE = 'https://api.github.com/repos/{owner}/{repo}/issues/{id}' HANDLE_MESSAGE_REGEX = re.compile("(?:([\w-]+)\/)?([\w-]+)?#(\d+)") - def initialize(self: Any, bot_handler: Any) -> None: + def initialize(self, bot_handler: Any) -> None: self.config_info = bot_handler.get_config_info('github_detail', optional=True) self.owner = self.config_info.get("owner", False) self.repo = self.config_info.get("repo", False) - def usage(self: Any) -> str: + def usage(self) -> str: return ("This plugin displays details on github issues and pull requests. " "To reference an issue or pull request usename mention the bot then " "anytime in the message type its id, for example:\n" "@**Github detail** #3212 zulip#3212 zulip/zulip#3212\n" "The default owner is {} and the default repo is {}.".format(self.owner, self.repo)) - def format_message(self: Any, details: Dict[str, Any]) -> str: + def format_message(self, details: Dict[str, Any]) -> str: number = details['number'] title = details['title'] link = details['html_url'] @@ -46,7 +46,7 @@ class GithubHandler(object): 'Status - **{status}**\n```quote\n{description}\n```'.format(status=status, description=description)) return ''.join(message_string) - def get_details_from_github(self: Any, owner: str, repo: str, number: str) -> Union[None, Dict[str, Union[str, int, bool]]]: + def get_details_from_github(self, owner: str, repo: str, number: str) -> Union[None, Dict[str, Union[str, int, bool]]]: # Gets the details of an issues or pull request try: r = requests.get( @@ -58,7 +58,7 @@ class GithubHandler(object): return None return r.json() - def get_owner_and_repo(self: Any, issue_pr: Any) -> Tuple[str, str]: + def get_owner_and_repo(self, issue_pr: Any) -> Tuple[str, str]: owner = issue_pr.group(1) repo = issue_pr.group(2) if owner is None: @@ -67,7 +67,7 @@ class GithubHandler(object): repo = self.repo return (owner, repo) - def handle_message(self: Any, message: Dict[str, str], bot_handler: Any) -> None: + def handle_message(self, message: Dict[str, str], bot_handler: Any) -> None: # Send help message if message['content'] == 'help': bot_handler.send_reply(message, self.usage()) diff --git a/zulip_bots/zulip_bots/bots/github_detail/test_github_detail.py b/zulip_bots/zulip_bots/bots/github_detail/test_github_detail.py index a886ae7..642089b 100755 --- a/zulip_bots/zulip_bots/bots/github_detail/test_github_detail.py +++ b/zulip_bots/zulip_bots/bots/github_detail/test_github_detail.py @@ -13,7 +13,7 @@ class TestGithubDetailBot(StubBotTestCase): mock_config = {'owner': 'zulip', 'repo': 'zulip'} # Overrides default test_bot_usage(). - def test_bot_usage(self: Any) -> None: + def test_bot_usage(self) -> None: bot = get_bot_message_handler(self.bot_name) bot_handler = StubBotHandler() @@ -22,7 +22,7 @@ class TestGithubDetailBot(StubBotTestCase): self.assertIn('displays details on github issues', bot.usage()) - def test_issue(self: Any) -> None: + def test_issue(self) -> None: request = 'zulip/zulip#5365' bot_response = '**[zulip/zulip#5365](https://github.com/zulip/zulip/issues/5365)'\ ' - frontend: Enable hot-reloading of CSS in development**\n'\ @@ -38,7 +38,7 @@ class TestGithubDetailBot(StubBotTestCase): with self.mock_config_info(self.mock_config): self.verify_reply(request, bot_response) - def test_pull_request(self: Any) -> None: + def test_pull_request(self) -> None: request = 'zulip/zulip#5345' bot_response = '**[zulip/zulip#5345](https://github.com/zulip/zulip/pull/5345)'\ ' - [WIP] modal: Replace bootstrap modal with custom modal class**\n'\ @@ -55,20 +55,20 @@ class TestGithubDetailBot(StubBotTestCase): with self.mock_config_info(self.mock_config): self.verify_reply(request, bot_response) - def test_404(self: Any) -> None: + def test_404(self) -> None: request = 'zulip/zulip#0' bot_response = 'Failed to find issue/pr: zulip/zulip#0' with self.mock_http_conversation('test_404'): with self.mock_config_info(self.mock_config): self.verify_reply(request, bot_response) - def test_random_text(self: Any) -> None: + def test_random_text(self) -> None: request = 'some random text' bot_response = 'Failed to find any issue or PR.' with self.mock_config_info(self.mock_config): self.verify_reply(request, bot_response) - def test_help_text(self: Any) -> None: + def test_help_text(self) -> None: request = 'help' bot_response = 'This plugin displays details on github issues and pull requests. '\ 'To reference an issue or pull request usename mention the bot then '\ diff --git a/zulip_bots/zulip_bots/bots/help/help.py b/zulip_bots/zulip_bots/bots/help/help.py index 3d116b3..5b878a1 100644 --- a/zulip_bots/zulip_bots/bots/help/help.py +++ b/zulip_bots/zulip_bots/bots/help/help.py @@ -2,7 +2,7 @@ from typing import Any, Dict class HelpHandler(object): - def usage(self: Any) -> str: + def usage(self) -> str: return ''' This plugin will give info about Zulip to any user that types a message saying "help". @@ -12,7 +12,7 @@ class HelpHandler(object): your Zulip instance. ''' - def handle_message(self: Any, message: Dict[str, str], bot_handler: Any) -> None: + def handle_message(self, message: Dict[str, str], bot_handler: Any) -> None: help_content = "Info on Zulip can be found here:\nhttps://github.com/zulip/zulip" bot_handler.send_reply(message, help_content) diff --git a/zulip_bots/zulip_bots/bots/help/test_help.py b/zulip_bots/zulip_bots/bots/help/test_help.py index d6e6210..32d2fc7 100755 --- a/zulip_bots/zulip_bots/bots/help/test_help.py +++ b/zulip_bots/zulip_bots/bots/help/test_help.py @@ -7,7 +7,7 @@ from typing import Any class TestHelpBot(StubBotTestCase): bot_name = "help" - def test_bot(self: Any) -> None: + def test_bot(self) -> None: help_text = "Info on Zulip can be found here:\nhttps://github.com/zulip/zulip" requests = ["", "help", "Hi, my name is abc"]