GeezerVison is showing github.com — flake8 revamp · saintbyte/python-telegram-bot@baec1bb
File treeExpand file treeCollapse file tree Open diff view settings Some content is hiddenLarge Commits have some content hidden by default. Use the searchbox below for content that may be hidden. Dismiss bannerExpand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: .pre-commit-config.yaml +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 6 | 6 | args: | 7 | 7 | - --diff | 8 | 8 | - repo: git://github.com/pre-commit/pre-commit-hooks | 9 | | - sha: 78818b90cd694c29333ba54d38f9e60b6359ccfc | | 9 | + sha: v1.2.0 | 10 | 10 | hooks: | 11 | 11 | - id: flake8 | 12 | | - files: ^telegram/.*\.py$ | | 12 | + exclude: ^(setup.py|docs/source/conf.py)$ | 13 | 13 | - repo: git://github.com/pre-commit/mirrors-pylint | 14 | 14 | sha: v1.7.1 | 15 | 15 | hooks: | |
Collapse file Copy file name to clipboardExpand all lines: examples/inlinebot.py -2Lines changed: 0 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 18 | 18 | """ | 19 | 19 | from uuid import uuid4 | 20 | 20 |
| 21 | | -import re | 22 | | - | 23 | 21 | from telegram.utils.helpers import escape_markdown | 24 | 22 |
| 25 | 23 | from telegram import InlineQueryResultArticle, ParseMode, \ | |
Collapse file Copy file name to clipboardExpand all lines: telegram/ext/jobqueue.py +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -283,7 +283,7 @@ def tick(self): | 283 | 283 | self.logger.debug('Running job %s', job.name) | 284 | 284 | job.run(self.bot) | 285 | 285 |
| 286 | | - except: | | 286 | + except Exception: | 287 | 287 | self.logger.exception('An uncaught error was raised while executing job %s', | 288 | 288 | job.name) | 289 | 289 | else: | |
Collapse file Copy file name to clipboardExpand all lines: tests/test_bot.py +1-2Lines changed: 1 addition & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 18 | 18 | # along with this program. If not, see [http://www.gnu.org/licenses/]. | 19 | 19 | import os | 20 | 20 | import time | 21 | | -from datetime import datetime, timedelta | | 21 | +from datetime import datetime | 22 | 22 | from platform import python_implementation | 23 | 23 |
| 24 | 24 | import pytest | @@ -552,7 +552,6 @@ def test_answer_pre_checkout_query_errors(self, monkeypatch, bot): | 552 | 552 | def test_restrict_chat_member(self, bot, channel_id): | 553 | 553 | # TODO: Add bot to supergroup so this can be tested properly | 554 | 554 | with pytest.raises(BadRequest, match='Method is available only for supergroups'): | 555 | | - until = datetime.now() + timedelta(seconds=30) | 556 | 555 | assert bot.restrict_chat_member(channel_id, | 557 | 556 | 95205500, | 558 | 557 | until_date=datetime.now(), | |
Collapse file Copy file name to clipboardExpand all lines: tests/test_constants.py +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -44,4 +44,4 @@ def test_max_caption_length(self, bot, chat_id): | 44 | 44 | bad_caption = good_caption + 'Z' | 45 | 45 | with pytest.raises(BadRequest, message="Media_caption_too_long"): | 46 | 46 | with open('tests/data/telegram.png', 'rb') as f: | 47 | | - bad_message = bot.send_photo(photo=f, caption=bad_caption, chat_id=chat_id) | | 47 | + bot.send_photo(photo=f, caption=bad_caption, chat_id=chat_id) |
Collapse file Copy file name to clipboardExpand all lines: tests/test_conversationhandler.py +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -88,8 +88,8 @@ def code(self, bot, update): | 88 | 88 | # Tests | 89 | 89 | def test_per_all_false(self): | 90 | 90 | with pytest.raises(ValueError, match="can't all be 'False'"): | 91 | | - handler = ConversationHandler(self.entry_points, self.states, self.fallbacks, | 92 | | - per_chat=False, per_user=False, per_message=False) | | 91 | + ConversationHandler(self.entry_points, self.states, self.fallbacks, | | 92 | + per_chat=False, per_user=False, per_message=False) | 93 | 93 |
| 94 | 94 | def test_conversation_handler(self, dp, bot, user1, user2): | 95 | 95 | handler = ConversationHandler(entry_points=self.entry_points, states=self.states, | |
Collapse file Copy file name to clipboardExpand all lines: tests/test_dispatcher.py +2-1Lines changed: 2 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -35,7 +35,8 @@ def dp2(bot): | 35 | 35 |
| 36 | 36 |
| 37 | 37 | class TestDispatcher(object): | 38 | | - message_update = Update(1, message=Message(1, User(1, '', False), None, Chat(1, ''), text='Text')) | | 38 | + message_update = Update(1, | | 39 | + message=Message(1, User(1, '', False), None, Chat(1, ''), text='Text')) | 39 | 40 | received = None | 40 | 41 | count = 0 | 41 | 42 |
| |
Collapse file Copy file name to clipboardExpand all lines: tests/test_inlinekeyboardbutton.py +6-6Lines changed: 6 additions & 6 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -48,8 +48,8 @@ def test_expected_values(self, inline_keyboard_button): | 48 | 48 | assert inline_keyboard_button.url == self.url | 49 | 49 | assert inline_keyboard_button.callback_data == self.callback_data | 50 | 50 | assert inline_keyboard_button.switch_inline_query == self.switch_inline_query | 51 | | - assert inline_keyboard_button.switch_inline_query_current_chat == \ | 52 | | - self.switch_inline_query_current_chat | | 51 | + assert (inline_keyboard_button.switch_inline_query_current_chat == | | 52 | + self.switch_inline_query_current_chat) | 53 | 53 | assert inline_keyboard_button.callback_game == self.callback_game | 54 | 54 | assert inline_keyboard_button.pay == self.pay | 55 | 55 |
| @@ -60,9 +60,9 @@ def test_to_dict(self, inline_keyboard_button): | 60 | 60 | assert inline_keyboard_button_dict['text'] == inline_keyboard_button.text | 61 | 61 | assert inline_keyboard_button_dict['url'] == inline_keyboard_button.url | 62 | 62 | assert inline_keyboard_button_dict['callback_data'] == inline_keyboard_button.callback_data | 63 | | - assert inline_keyboard_button_dict['switch_inline_query'] == \ | 64 | | - inline_keyboard_button.switch_inline_query | 65 | | - assert inline_keyboard_button_dict['switch_inline_query_current_chat'] == \ | 66 | | - inline_keyboard_button.switch_inline_query_current_chat | | 63 | + assert (inline_keyboard_button_dict['switch_inline_query'] == | | 64 | + inline_keyboard_button.switch_inline_query) | | 65 | + assert (inline_keyboard_button_dict['switch_inline_query_current_chat'] == | | 66 | + inline_keyboard_button.switch_inline_query_current_chat) | 67 | 67 | assert inline_keyboard_button_dict['callback_game'] == inline_keyboard_button.callback_game | 68 | 68 | assert inline_keyboard_button_dict['pay'] == inline_keyboard_button.pay |
Collapse file Copy file name to clipboardExpand all lines: tests/test_inlinequeryresultarticle.py +25-24Lines changed: 25 additions & 24 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 25 | 25 |
| 26 | 26 | @pytest.fixture(scope='class') | 27 | 27 | def inline_query_result_article(): | 28 | | - return InlineQueryResultArticle(TestInlineQueryResultArticle.id, | 29 | | - TestInlineQueryResultArticle.title, | 30 | | - input_message_content=TestInlineQueryResultArticle.input_message_content, | 31 | | - reply_markup=TestInlineQueryResultArticle.reply_markup, | 32 | | - url=TestInlineQueryResultArticle.url, | 33 | | - hide_url=TestInlineQueryResultArticle.hide_url, | 34 | | - description=TestInlineQueryResultArticle.description, | 35 | | - thumb_url=TestInlineQueryResultArticle.thumb_url, | 36 | | - thumb_height=TestInlineQueryResultArticle.thumb_height, | 37 | | - thumb_width=TestInlineQueryResultArticle.thumb_width) | | 28 | + return InlineQueryResultArticle( | | 29 | + TestInlineQueryResultArticle.id, | | 30 | + TestInlineQueryResultArticle.title, | | 31 | + input_message_content=TestInlineQueryResultArticle.input_message_content, | | 32 | + reply_markup=TestInlineQueryResultArticle.reply_markup, | | 33 | + url=TestInlineQueryResultArticle.url, | | 34 | + hide_url=TestInlineQueryResultArticle.hide_url, | | 35 | + description=TestInlineQueryResultArticle.description, | | 36 | + thumb_url=TestInlineQueryResultArticle.thumb_url, | | 37 | + thumb_height=TestInlineQueryResultArticle.thumb_height, | | 38 | + thumb_width=TestInlineQueryResultArticle.thumb_width) | 38 | 39 |
| 39 | 40 |
| 40 | 41 | class TestInlineQueryResultArticle(object): | @@ -54,8 +55,8 @@ def test_expected_values(self, inline_query_result_article): | 54 | 55 | assert inline_query_result_article.type == self.type | 55 | 56 | assert inline_query_result_article.id == self.id | 56 | 57 | assert inline_query_result_article.title == self.title | 57 | | - assert inline_query_result_article.input_message_content.to_dict() == \ | 58 | | - self.input_message_content.to_dict() | | 58 | + assert (inline_query_result_article.input_message_content.to_dict() == | | 59 | + self.input_message_content.to_dict()) | 59 | 60 | assert inline_query_result_article.reply_markup.to_dict() == self.reply_markup.to_dict() | 60 | 61 | assert inline_query_result_article.url == self.url | 61 | 62 | assert inline_query_result_article.hide_url == self.hide_url | @@ -71,20 +72,20 @@ def test_to_dict(self, inline_query_result_article): | 71 | 72 | assert inline_query_result_article_dict['type'] == inline_query_result_article.type | 72 | 73 | assert inline_query_result_article_dict['id'] == inline_query_result_article.id | 73 | 74 | assert inline_query_result_article_dict['title'] == inline_query_result_article.title | 74 | | - assert inline_query_result_article_dict['input_message_content'] == \ | 75 | | - inline_query_result_article.input_message_content.to_dict() | 76 | | - assert inline_query_result_article_dict['reply_markup'] == \ | 77 | | - inline_query_result_article.reply_markup.to_dict() | | 75 | + assert (inline_query_result_article_dict['input_message_content'] == | | 76 | + inline_query_result_article.input_message_content.to_dict()) | | 77 | + assert (inline_query_result_article_dict['reply_markup'] == | | 78 | + inline_query_result_article.reply_markup.to_dict()) | 78 | 79 | assert inline_query_result_article_dict['url'] == inline_query_result_article.url | 79 | 80 | assert inline_query_result_article_dict['hide_url'] == inline_query_result_article.hide_url | 80 | | - assert inline_query_result_article_dict['description'] == \ | 81 | | - inline_query_result_article.description | 82 | | - assert inline_query_result_article_dict['thumb_url'] == \ | 83 | | - inline_query_result_article.thumb_url | 84 | | - assert inline_query_result_article_dict['thumb_height'] == \ | 85 | | - inline_query_result_article.thumb_height | 86 | | - assert inline_query_result_article_dict['thumb_width'] == \ | 87 | | - inline_query_result_article.thumb_width | | 81 | + assert (inline_query_result_article_dict['description'] == | | 82 | + inline_query_result_article.description) | | 83 | + assert (inline_query_result_article_dict['thumb_url'] == | | 84 | + inline_query_result_article.thumb_url) | | 85 | + assert (inline_query_result_article_dict['thumb_height'] == | | 86 | + inline_query_result_article.thumb_height) | | 87 | + assert (inline_query_result_article_dict['thumb_width'] == | | 88 | + inline_query_result_article.thumb_width) | 88 | 89 |
| 89 | 90 | def test_equality(self): | 90 | 91 | a = InlineQueryResultArticle(self.id, self.title, self.input_message_content) | |
Collapse file Copy file name to clipboardExpand all lines: tests/test_inlinequeryresultaudio.py +18-17Lines changed: 18 additions & 17 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 25 | 25 |
| 26 | 26 | @pytest.fixture(scope='class') | 27 | 27 | def inline_query_result_audio(): | 28 | | - return InlineQueryResultAudio(TestInlineQueryResultAudio.id, | 29 | | - TestInlineQueryResultAudio.audio_url, | 30 | | - TestInlineQueryResultAudio.title, | 31 | | - performer=TestInlineQueryResultAudio.performer, | 32 | | - audio_duration=TestInlineQueryResultAudio.audio_duration, | 33 | | - caption=TestInlineQueryResultAudio.caption, | 34 | | - parse_mode=TestInlineQueryResultAudio.parse_mode, | 35 | | - input_message_content=TestInlineQueryResultAudio.input_message_content, | 36 | | - reply_markup=TestInlineQueryResultAudio.reply_markup) | | 28 | + return InlineQueryResultAudio( | | 29 | + TestInlineQueryResultAudio.id, | | 30 | + TestInlineQueryResultAudio.audio_url, | | 31 | + TestInlineQueryResultAudio.title, | | 32 | + performer=TestInlineQueryResultAudio.performer, | | 33 | + audio_duration=TestInlineQueryResultAudio.audio_duration, | | 34 | + caption=TestInlineQueryResultAudio.caption, | | 35 | + parse_mode=TestInlineQueryResultAudio.parse_mode, | | 36 | + input_message_content=TestInlineQueryResultAudio.input_message_content, | | 37 | + reply_markup=TestInlineQueryResultAudio.reply_markup) | 37 | 38 |
| 38 | 39 |
| 39 | 40 | class TestInlineQueryResultAudio(object): | @@ -57,8 +58,8 @@ def test_expected_values(self, inline_query_result_audio): | 57 | 58 | assert inline_query_result_audio.audio_duration == self.audio_duration | 58 | 59 | assert inline_query_result_audio.caption == self.caption | 59 | 60 | assert inline_query_result_audio.parse_mode == self.parse_mode | 60 | | - assert inline_query_result_audio.input_message_content.to_dict() == \ | 61 | | - self.input_message_content.to_dict() | | 61 | + assert (inline_query_result_audio.input_message_content.to_dict() == | | 62 | + self.input_message_content.to_dict()) | 62 | 63 | assert inline_query_result_audio.reply_markup.to_dict() == self.reply_markup.to_dict() | 63 | 64 |
| 64 | 65 | def test_to_dict(self, inline_query_result_audio): | @@ -70,14 +71,14 @@ def test_to_dict(self, inline_query_result_audio): | 70 | 71 | assert inline_query_result_audio_dict['audio_url'] == inline_query_result_audio.audio_url | 71 | 72 | assert inline_query_result_audio_dict['title'] == inline_query_result_audio.title | 72 | 73 | assert inline_query_result_audio_dict['performer'] == inline_query_result_audio.performer | 73 | | - assert inline_query_result_audio_dict['audio_duration'] == \ | 74 | | - inline_query_result_audio.audio_duration | | 74 | + assert (inline_query_result_audio_dict['audio_duration'] == | | 75 | + inline_query_result_audio.audio_duration) | 75 | 76 | assert inline_query_result_audio_dict['caption'] == inline_query_result_audio.caption | 76 | 77 | assert inline_query_result_audio_dict['parse_mode'] == inline_query_result_audio.parse_mode | 77 | | - assert inline_query_result_audio_dict['input_message_content'] == \ | 78 | | - inline_query_result_audio.input_message_content.to_dict() | 79 | | - assert inline_query_result_audio_dict['reply_markup'] == \ | 80 | | - inline_query_result_audio.reply_markup.to_dict() | | 78 | + assert (inline_query_result_audio_dict['input_message_content'] == | | 79 | + inline_query_result_audio.input_message_content.to_dict()) | | 80 | + assert (inline_query_result_audio_dict['reply_markup'] == | | 81 | + inline_query_result_audio.reply_markup.to_dict()) | 81 | 82 |
| 82 | 83 | def test_equality(self): | 83 | 84 | a = InlineQueryResultAudio(self.id, self.audio_url, self.title) | |
|