From feec1dde566ef0de96cf698b58c94f9899649fa5 Mon Sep 17 00:00:00 2001 From: uburuntu Date: Fri, 17 Aug 2018 12:49:37 +0300 Subject: [PATCH] fix: little style fixes --- examples/deep_linking.py | 1 - examples/step_example.py | 1 - telebot/__init__.py | 4 ++-- telebot/apihelper.py | 6 ++++-- telebot/util.py | 2 +- tests/test_telebot.py | 3 ++- tests/test_types.py | 2 +- 7 files changed, 10 insertions(+), 9 deletions(-) diff --git a/examples/deep_linking.py b/examples/deep_linking.py index f92680f..91fcb15 100644 --- a/examples/deep_linking.py +++ b/examples/deep_linking.py @@ -31,7 +31,6 @@ # steps are not shown here. Only steps 5 to 7 are illustrated, some in pseudo-code, with this example. import telebot -import time bot = telebot.TeleBot('TOKEN') diff --git a/examples/step_example.py b/examples/step_example.py index 0fc0ef1..fea047e 100644 --- a/examples/step_example.py +++ b/examples/step_example.py @@ -2,7 +2,6 @@ """ This Example will show you how to use register_next_step handler. """ -import time import telebot from telebot import types diff --git a/telebot/__init__.py b/telebot/__init__.py index 7865d94..5a4ec35 100644 --- a/telebot/__init__.py +++ b/telebot/__init__.py @@ -1294,14 +1294,14 @@ class TeleBot: was_poped = False if chat_id in self.next_step_handlers.keys(): handlers = self.next_step_handlers.pop(chat_id, None) - if (handlers): + if handlers: for handler in handlers: self._exec_task(handler["callback"], message, *handler["args"], **handler["kwargs"]) new_messages.pop(i) # removing message that detects with next_step_handler was_poped = True if self.next_step_saver is not None: self.next_step_saver.start_save_timer() - if (not was_poped): + if not was_poped: i += 1 diff --git a/telebot/apihelper.py b/telebot/apihelper.py index ae72e37..e36bcd7 100644 --- a/telebot/apihelper.py +++ b/telebot/apihelper.py @@ -99,7 +99,6 @@ def get_file(token, file_id): def get_file_url(token, file_id): - method_url = r'getFile' return FILE_URL.format(token, get_file(token, file_id).file_path) @@ -123,6 +122,8 @@ def send_message(token, chat_id, text, disable_web_page_preview=None, reply_to_m :param disable_web_page_preview: :param reply_to_message_id: :param reply_markup: + :param parse_mode: + :param disable_notification: :return: """ method_url = r'sendMessage' @@ -769,7 +770,8 @@ def send_invoice(token, chat_id, title, description, invoice_payload, provider_t :param disable_notification: Sends the message silently. Users will receive a notification with no sound. :param reply_to_message_id: If the message is a reply, ID of the original message :param reply_markup: A JSON-serialized object for an inline keyboard. If empty, one 'Pay total price' button will be shown. If not empty, the first button must be a Pay button - :return: + :param provider_data: + :return: """ method_url = r'sendInvoice' payload = {'chat_id': chat_id, 'title': title, 'description': description, 'payload': invoice_payload, diff --git a/telebot/util.py b/telebot/util.py index f448d78..e7af2c7 100644 --- a/telebot/util.py +++ b/telebot/util.py @@ -243,7 +243,7 @@ def extract_arguments(text): :param text: String to extract the arguments from a command :return: the arguments if `text` is a command (according to is_command), else None. """ - regexp = re.compile("\/\w*(@\w*)*\s*([\s\S]*)",re.IGNORECASE) + regexp = re.compile("/\w*(@\w*)*\s*([\s\S]*)",re.IGNORECASE) result = regexp.match(text) return result.group(2) if is_command(text) else None diff --git a/tests/test_telebot.py b/tests/test_telebot.py index b81485e..908b141 100644 --- a/tests/test_telebot.py +++ b/tests/test_telebot.py @@ -402,7 +402,8 @@ class TestTeleBot: new_msg = tb.edit_message_reply_markup(chat_id=CHAT_ID, message_id=ret_msg.message_id, reply_markup=markup) assert new_msg.message_id - def create_text_message(self, text): + @staticmethod + def create_text_message(text): params = {'text': text} chat = types.User(11, False, 'test') return types.Message(1, None, None, chat, 'text', params, "") diff --git a/tests/test_types.py b/tests/test_types.py index c174d42..42e285b 100644 --- a/tests/test_types.py +++ b/tests/test_types.py @@ -59,7 +59,7 @@ def test_json_Message_Sticker_without_thumb(): json_string = r'{"message_id":98,"from":{"id":10734,"first_name":"Fd","last_name":"Wd","username":"dd","is_bot":true },"chat":{"id":10734,"first_name":"Fd","type":"private","last_name":"Wd","username":"dd"},"date":1435479551,"sticker":{"width":550,"height":368,"file_id":"BQADBQADNAIAAsYifgYdGJOa6bGAsQI","file_size":30320}}' msg = types.Message.de_json(json_string) assert msg.sticker.height == 368 - assert msg.sticker.thumb == None + assert msg.sticker.thumb is None assert msg.content_type == 'sticker'