From 11a3de67eabe9964b30709b7670c4d7d55eafa1b Mon Sep 17 00:00:00 2001 From: Dickson Tan Date: Tue, 25 Apr 2017 16:39:02 +0800 Subject: [PATCH] Remove deprecated code #408 part 1 (#564) * Remove non-pep8 dispatcher methods * callbackqueryhandler: Remove non-pep8 compliant methods * commandhandler: Remove non-pep8 compliant methods * handler: Remove non-pep8 compliant methods * messagehandler: Remove non-pep8 compliant methods * stringcommandhandler: Remove non-pep8 compliant methods * stringregexhandler: Remove non-pep8 compliant methods * test_updater: fix usage of deprecated methods * dispatcher: fix accidental misalignment of comments by pre-commit hook * Add myself to list of contributors --- AUTHORS.rst | 1 + telegram/ext/callbackqueryhandler.py | 6 ------ telegram/ext/commandhandler.py | 6 ------ telegram/ext/dispatcher.py | 9 --------- telegram/ext/handler.py | 9 --------- telegram/ext/messagehandler.py | 6 ------ telegram/ext/stringcommandhandler.py | 6 ------ telegram/ext/stringregexhandler.py | 6 ------ tests/test_updater.py | 10 +++++----- 9 files changed, 6 insertions(+), 53 deletions(-) diff --git a/AUTHORS.rst b/AUTHORS.rst index b39f7fed4..3d9de0553 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -32,6 +32,7 @@ The following wonderful people contributed directly or indirectly to this projec - `macrojames `_ - `Michael Elovskikh `_ - `naveenvhegde `_ +- `neurrone `_ - `njittam `_ - `Noam Meltzer `_ - `Oleg Shlyazhko `_ diff --git a/telegram/ext/callbackqueryhandler.py b/telegram/ext/callbackqueryhandler.py index e20d5c085..3f7d1e69f 100644 --- a/telegram/ext/callbackqueryhandler.py +++ b/telegram/ext/callbackqueryhandler.py @@ -23,7 +23,6 @@ import re from future.utils import string_types from telegram import Update -from telegram.utils.deprecate import deprecate from .handler import Handler @@ -105,8 +104,3 @@ class CallbackQueryHandler(Handler): optional_args['groupdict'] = match.groupdict() return self.callback(dispatcher.bot, update, **optional_args) - - # old non-PEP8 Handler methods - m = "telegram.CallbackQueryHandler." - checkUpdate = deprecate(check_update, m + "checkUpdate", m + "check_update") - handleUpdate = deprecate(handle_update, m + "handleUpdate", m + "handle_update") diff --git a/telegram/ext/commandhandler.py b/telegram/ext/commandhandler.py index 52bc02ac4..f136d3761 100644 --- a/telegram/ext/commandhandler.py +++ b/telegram/ext/commandhandler.py @@ -21,7 +21,6 @@ import warnings from .handler import Handler from telegram import Update -from telegram.utils.deprecate import deprecate class CommandHandler(Handler): @@ -126,8 +125,3 @@ class CommandHandler(Handler): optional_args['args'] = message.text.split()[1:] return self.callback(dispatcher.bot, update, **optional_args) - - # old non-PEP8 Handler methods - m = "telegram.CommandHandler." - checkUpdate = deprecate(check_update, m + "checkUpdate", m + "check_update") - handleUpdate = deprecate(handle_update, m + "handleUpdate", m + "handle_update") diff --git a/telegram/ext/dispatcher.py b/telegram/ext/dispatcher.py index c551a33d4..24658798d 100644 --- a/telegram/ext/dispatcher.py +++ b/telegram/ext/dispatcher.py @@ -32,7 +32,6 @@ from future.builtins import range from telegram import TelegramError from telegram.ext.handler import Handler -from telegram.utils.deprecate import deprecate from telegram.utils.promise import Promise logging.getLogger(__name__).addHandler(logging.NullHandler()) @@ -368,11 +367,3 @@ class Dispatcher(object): for callback in self.error_handlers: callback(self.bot, update, error) - - # old non-PEP8 Dispatcher methods - m = "telegram.dispatcher." - addHandler = deprecate(add_handler, m + "AddHandler", m + "add_handler") - removeHandler = deprecate(remove_handler, m + "removeHandler", m + "remove_handler") - addErrorHandler = deprecate(add_error_handler, m + "addErrorHandler", m + "add_error_handler") - removeErrorHandler = deprecate(remove_error_handler, m + "removeErrorHandler", - m + "remove_error_handler") diff --git a/telegram/ext/handler.py b/telegram/ext/handler.py index ade606df3..ecca8a41b 100644 --- a/telegram/ext/handler.py +++ b/telegram/ext/handler.py @@ -19,8 +19,6 @@ """ This module contains the base class for handlers as used by the Dispatcher """ -from telegram.utils.deprecate import deprecate - class Handler(object): """ @@ -114,10 +112,3 @@ class Handler(object): optional_args['chat_data'] = dispatcher.chat_data[chat.id if chat else None] return optional_args - - # old non-PEP8 Handler methods - m = "telegram.Handler." - checkUpdate = deprecate(check_update, m + "checkUpdate", m + "check_update") - handleUpdate = deprecate(handle_update, m + "handleUpdate", m + "handle_update") - collectOptionalArgs = deprecate(collect_optional_args, m + "collectOptionalArgs", - m + "collect_optional_args") diff --git a/telegram/ext/messagehandler.py b/telegram/ext/messagehandler.py index 50b844263..85ab1b72e 100644 --- a/telegram/ext/messagehandler.py +++ b/telegram/ext/messagehandler.py @@ -21,7 +21,6 @@ import warnings from .handler import Handler from telegram import Update -from telegram.utils.deprecate import deprecate class MessageHandler(Handler): @@ -120,8 +119,3 @@ class MessageHandler(Handler): optional_args = self.collect_optional_args(dispatcher, update) return self.callback(dispatcher.bot, update, **optional_args) - - # old non-PEP8 Handler methods - m = "telegram.MessageHandler." - checkUpdate = deprecate(check_update, m + "checkUpdate", m + "check_update") - handleUpdate = deprecate(handle_update, m + "handleUpdate", m + "handle_update") diff --git a/telegram/ext/stringcommandhandler.py b/telegram/ext/stringcommandhandler.py index 45826c7e7..648467701 100644 --- a/telegram/ext/stringcommandhandler.py +++ b/telegram/ext/stringcommandhandler.py @@ -19,7 +19,6 @@ """ This module contains the StringCommandHandler class """ from .handler import Handler -from telegram.utils.deprecate import deprecate class StringCommandHandler(Handler): @@ -69,8 +68,3 @@ class StringCommandHandler(Handler): optional_args['args'] = update.split()[1:] return self.callback(dispatcher.bot, update, **optional_args) - - # old non-PEP8 Handler methods - m = "telegram.StringCommandHandler." - checkUpdate = deprecate(check_update, m + "checkUpdate", m + "check_update") - handleUpdate = deprecate(handle_update, m + "handleUpdate", m + "handle_update") diff --git a/telegram/ext/stringregexhandler.py b/telegram/ext/stringregexhandler.py index 75b555eb7..dce4f7a86 100644 --- a/telegram/ext/stringregexhandler.py +++ b/telegram/ext/stringregexhandler.py @@ -23,7 +23,6 @@ import re from future.utils import string_types from .handler import Handler -from telegram.utils.deprecate import deprecate class StringRegexHandler(Handler): @@ -84,8 +83,3 @@ class StringRegexHandler(Handler): optional_args['groupdict'] = match.groupdict() return self.callback(dispatcher.bot, update, **optional_args) - - # old non-PEP8 Handler methods - m = "telegram.StringRegexHandler." - checkUpdate = deprecate(check_update, m + "checkUpdate", m + "check_update") - handleUpdate = deprecate(handle_update, m + "handleUpdate", m + "handle_update") diff --git a/tests/test_updater.py b/tests/test_updater.py index 123510e79..676ccd18d 100644 --- a/tests/test_updater.py +++ b/tests/test_updater.py @@ -189,15 +189,15 @@ class UpdaterTest(BaseTest, unittest.TestCase): d = self.updater.dispatcher from telegram.ext import Filters handler = MessageHandler(Filters.text, self.telegramHandlerEditedTest, allow_edited=True) - d.addHandler(handler) + d.add_handler(handler) self.updater.start_polling(0.01) sleep(.1) self.assertEqual(self.received_message, 'Test') # Remove handler - d.removeHandler(handler) + d.remove_handler(handler) handler = MessageHandler(Filters.text, self.telegramHandlerEditedTest, allow_edited=False) - d.addHandler(handler) + d.add_handler(handler) self.reset() self.updater.bot.send_messages = 1 @@ -263,9 +263,9 @@ class UpdaterTest(BaseTest, unittest.TestCase): self.assertTrue(None is self.received_message) # Remove handler - d.removeHandler(handler) + d.remove_handler(handler) handler = CommandHandler('test', self.telegramHandlerEditedTest, allow_edited=False) - d.addHandler(handler) + d.add_handler(handler) self.reset() self.updater.bot.send_messages = 1