-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sourcery refactored master branch #2
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Due to GitHub API limits, only the first 60 comments can be shown.
if not len(message.command) == 1: | ||
if len(message.command) != 1: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function resume_com
refactored with the following changes:
- Simplify logical expression using De Morgan identities (
de-morgan
)
else: | ||
if ( | ||
elif ( | ||
duration_seconds - (duration_played + duration_to_skip) | ||
) <= 10: | ||
return await message.reply_text( | ||
_["admin_31"].format( | ||
seconds_to_min(duration_played), duration | ||
) | ||
return await message.reply_text( | ||
_["admin_31"].format( | ||
seconds_to_min(duration_played), duration | ||
) | ||
) | ||
else: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function seek_comm
refactored with the following changes:
- Merge else clause's nested if statement into elif (
merge-else-if-into-elif
) - Lift code into else after jump in control flow (
reintroduce-else
)
if not len(message.command) == 1: | ||
if len(message.command) != 1: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function admins
refactored with the following changes:
- Simplify logical expression using De Morgan identities (
de-morgan
)
if not len(message.command) < 2: | ||
if len(message.command) >= 2: | ||
loop = await get_loop(chat_id) | ||
if loop != 0: | ||
return await message.reply_text(_["admin_12"]) | ||
state = message.text.split(None, 1)[1].strip() | ||
if state.isnumeric(): | ||
state = int(state) | ||
check = db.get(chat_id) | ||
if check: | ||
count = len(check) | ||
if count > 2: | ||
count = int(count - 1) | ||
if 1 <= state <= count: | ||
for x in range(state): | ||
popped = None | ||
try: | ||
popped = check.pop(0) | ||
except: | ||
return await message.reply_text( | ||
_["admin_16"] | ||
) | ||
if popped: | ||
if ( | ||
config.AUTO_DOWNLOADS_CLEAR | ||
== str(True) | ||
): | ||
await auto_clean(popped) | ||
if not check: | ||
try: | ||
await message.reply_text( | ||
_["admin_10"].format( | ||
message.from_user.first_name | ||
) | ||
) | ||
await Amang.stop_stream(chat_id) | ||
except: | ||
return | ||
break | ||
else: | ||
return await message.reply_text( | ||
_["admin_15"].format(count) | ||
) | ||
else: | ||
return await message.reply_text(_["admin_14"]) | ||
else: | ||
return await message.reply_text(_["queue_2"]) | ||
else: | ||
if not state.isnumeric(): | ||
return await message.reply_text(_["admin_13"]) | ||
state = int(state) | ||
check = db.get(chat_id) | ||
if not check: | ||
return await message.reply_text(_["queue_2"]) | ||
count = len(check) | ||
if count <= 2: | ||
return await message.reply_text(_["admin_14"]) | ||
count = int(count - 1) | ||
if not 1 <= state <= count: | ||
return await message.reply_text( | ||
_["admin_15"].format(count) | ||
) | ||
for _ in range(state): | ||
popped = None | ||
try: | ||
popped = check.pop(0) | ||
except: | ||
return await message.reply_text( | ||
_["admin_16"] | ||
) | ||
if popped and (config.AUTO_DOWNLOADS_CLEAR == str(True)): | ||
await auto_clean(popped) | ||
if not check: | ||
try: | ||
await message.reply_text( | ||
_["admin_10"].format( | ||
message.from_user.first_name | ||
) | ||
) | ||
await Amang.stop_stream(chat_id) | ||
except: | ||
return | ||
break | ||
else: | ||
check = db.get(chat_id) | ||
popped = None | ||
try: | ||
popped = check.pop(0) | ||
if popped: | ||
if popped := check.pop(0): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function skip
refactored with the following changes:
- Simplify logical expression using De Morgan identities (
de-morgan
) - Swap if/else branches [×4] (
swap-if-else-branches
) - Remove unnecessary else after guard condition [×4] (
remove-unnecessary-else
) - Replace unused for index with underscore (
for-index-underscore
) - Merge nested if conditions (
merge-nested-ifs
) - Use named expression to simplify assignment and conditional (
use-named-expression
) - Swap positions of nested conditionals [×12] (
swap-nested-ifs
)
if not len(message.command) == 1: | ||
if len(message.command) != 1: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function stop_music
refactored with the following changes:
- Simplify logical expression using De Morgan identities (
de-morgan
)
if not len(message.command) == 1 or message.reply_to_message: | ||
if len(message.command) != 1 or message.reply_to_message: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function unmute_admin
refactored with the following changes:
- Simplify logical expression using De Morgan identities (
de-morgan
)
else: | ||
await CallbackQuery.edit_message_text( | ||
helpers.HELP_5, reply_markup=keyboard | ||
) | ||
return await CallbackQuery.answer() | ||
await CallbackQuery.edit_message_text( | ||
helpers.HELP_5, reply_markup=keyboard | ||
) | ||
return await CallbackQuery.answer() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function helper_cb
refactored with the following changes:
- Swap if/else branches [×2] (
swap-if-else-branches
) - Remove unnecessary else after guard condition (
remove-unnecessary-else
)
@@ -20,7 +20,6 @@ | |||
@app.on_inline_query(~BANNED_USERS) | |||
async def inline_query_handler(client, query): | |||
text = query.query.strip().lower() | |||
answers = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function inline_query_handler
refactored with the following changes:
- Move assignments closer to their usage (
move-assign
)
cle = None | ||
if await is_cleanmode_on(CallbackQuery.message.chat.id): | ||
cle = True | ||
cle = True if await is_cleanmode_on(CallbackQuery.message.chat.id) else None | ||
if await is_commanddelete_on(CallbackQuery.message.chat.id): | ||
sta = True | ||
sug = None | ||
if await is_suggestion(CallbackQuery.message.chat.id): | ||
sug = True | ||
sug = True if await is_suggestion(CallbackQuery.message.chat.id) else None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function without_Admin_rights
refactored with the following changes:
- Move setting of default value for variable into
else
branch [×2] (introduce-default-else
) - Replace if statement with if expression [×6] (
assign-if-exp
) - Swap if/else branches of if expression to remove negation [×2] (
swap-if-expression
)
if playmode == "Direct": | ||
Direct = True | ||
else: | ||
Direct = None | ||
Direct = True if playmode == "Direct" else None | ||
playty = await get_playtype(CallbackQuery.message.chat.id) | ||
if playty == "Everyone": | ||
Playtype = None | ||
else: | ||
Playtype = True | ||
Playtype = None if playty == "Everyone" else True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function playmode_ans
refactored with the following changes:
- Replace if statement with if expression [×6] (
assign-if-exp
) - Simplify boolean if expression (
boolean-if-exp-identity
) - Swap if/else branches of if expression to remove negation [×2] (
swap-if-expression
) - Remove unnecessary casts to int, str, float or bool (
remove-unnecessary-cast
)
f9988ad
to
70cc70b
Compare
Branch
master
refactored 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
master
branch, then run:Help us improve this pull request!