Repository navigation
Sourcery refactored master branch - #1
sourcery-ai[bot] wants to merge 1 commit into
Conversation
| sex = message.text | ||
| user = user_dict[chat_id] | ||
| if (sex == u'Male') or (sex == u'Female'): | ||
| if sex in [u'Male', u'Female']: |
There was a problem hiding this comment.
Function process_sex_step refactored with the following changes:
- Replace multiple comparisons of same variable with
inoperator (merge-comparisons)
| self.finish() | ||
| else: | ||
| self.write("What are you doing here?") | ||
| self.finish() | ||
|
|
||
| self.finish() |
There was a problem hiding this comment.
Function webhook_serv.post refactored with the following changes:
- Hoist repeated code outside conditional statement (
hoist-statement-from-if)
| if len(new_messages) > 0: | ||
| if new_messages: | ||
| self.process_new_messages(new_messages) | ||
| if len(edited_new_messages) > 0: | ||
| if edited_new_messages: | ||
| self.process_new_edited_messages(edited_new_messages) | ||
| if len(new_channel_posts) > 0: | ||
| if new_channel_posts: | ||
| self.process_new_channel_posts(new_channel_posts) | ||
| if len(new_edited_channel_posts) > 0: | ||
| if new_edited_channel_posts: | ||
| self.process_new_edited_channel_posts(new_edited_channel_posts) | ||
| if len(new_inline_querys) > 0: | ||
| if new_inline_querys: | ||
| self.process_new_inline_query(new_inline_querys) | ||
| if len(new_chosen_inline_results) > 0: | ||
| if new_chosen_inline_results: | ||
| self.process_new_chosen_inline_query(new_chosen_inline_results) | ||
| if len(new_callback_querys) > 0: | ||
| if new_callback_querys: | ||
| self.process_new_callback_query(new_callback_querys) | ||
| if len(new_pre_checkout_querys) > 0: | ||
| if new_pre_checkout_querys: | ||
| self.process_new_pre_checkout_query(new_pre_checkout_querys) | ||
| if len(new_shipping_querys) > 0: | ||
| if new_shipping_querys: |
There was a problem hiding this comment.
Function TeleBot.process_new_updates refactored with the following changes:
- Simplify sequence comparison (
simplify-len-comparison)
| self.polling(timeout=timeout, *args, **kwargs) | ||
| except Exception as e: | ||
| time.sleep(timeout) | ||
| pass |
There was a problem hiding this comment.
Function TeleBot.infinity_polling refactored with the following changes:
- Remove redundant pass statement (
remove-redundant-pass)
| result = apihelper.leave_chat(self.token, chat_id) | ||
| return result | ||
| return apihelper.leave_chat(self.token, chat_id) |
There was a problem hiding this comment.
Function TeleBot.leave_chat refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
| btn_array = [] | ||
| for button in args: | ||
| btn_array.append(button.to_dic()) | ||
| btn_array = [button.to_dic() for button in args] |
There was a problem hiding this comment.
Function InlineKeyboardMarkup.row refactored with the following changes:
- Convert for loop into list comprehension (
list-comprehension)
| json_dict = {'inline_keyboard': self.keyboard} | ||
| return json_dict | ||
| return {'inline_keyboard': self.keyboard} |
There was a problem hiding this comment.
Function InlineKeyboardMarkup.to_dic refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
| ret = [] | ||
| for ps in photo_size_array: | ||
| ret.append(PhotoSize.de_json(ps)) | ||
| return ret | ||
| return [PhotoSize.de_json(ps) for ps in photo_size_array] |
There was a problem hiding this comment.
Function Game.parse_photo refactored with the following changes:
- Convert for loop into list comprehension (
list-comprehension) - Inline variable that is immediately returned (
inline-immediately-returned-variable)
| ret = [] | ||
| for me in message_entity_array: | ||
| ret.append(MessageEntity.de_json(me)) | ||
| return ret | ||
| return [MessageEntity.de_json(me) for me in message_entity_array] |
There was a problem hiding this comment.
Function Game.parse_entities refactored with the following changes:
- Convert for loop into list comprehension (
list-comprehension) - Inline variable that is immediately returned (
inline-immediately-returned-variable)
| price_list = [] | ||
| for p in self.prices: | ||
| price_list.append(p.to_dic()) | ||
| json_dict = json.dumps({'id': self.id, 'title': self.title, 'prices': price_list}) | ||
| return json_dict | ||
| price_list = [p.to_dic() for p in self.prices] | ||
| return json.dumps({'id': self.id, 'title': self.title, 'prices': price_list}) |
There was a problem hiding this comment.
Function ShippingOption.to_json refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable) - Convert for loop into list comprehension (
list-comprehension)
| ret = super(InputMediaPhoto, self).to_dic() | ||
| return ret | ||
| return super(InputMediaPhoto, self).to_dic() |
There was a problem hiding this comment.
Function InputMediaPhoto.to_dic refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable)
Sourcery Code Quality Report (beta)✅ Merging this PR will increase code quality in the affected files by 0.01 out of 10.
Here are some functions in these files that still need a tune-up:
Please see our documentation here for details on how these metrics are calculated. We are actively working on this report - lots more documentation and extra metrics to come! |
Branch
masterrefactored by Sourcery.If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.
See our documentation here.
Run Sourcery locally
Reduce the feedback loop during development by using the Sourcery editor plugin:
Review changes via command line
To manually merge these changes, make sure you're on the
masterbranch, then run: