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 main branch #1
Conversation
if is_exist: | ||
return True | ||
else: | ||
return False | ||
return bool(is_exist) |
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 is_user_in_db
refactored with the following changes:
- Simplify boolean if expression (
boolean-if-exp-identity
) - Replace if statement with if expression (
assign-if-exp
)
if is_exist: | ||
return True | ||
else: | ||
return False | ||
return bool(is_exist) |
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 is_user_in_bdb
refactored with the following changes:
- Simplify boolean if expression (
boolean-if-exp-identity
) - Replace if statement with if expression (
assign-if-exp
)
''.join(["░" for i in range(20 - math.floor(percentage / 5))]), | ||
round(percentage, 2)) | ||
''.join(["░" for _ in range(20 - math.floor(percentage / 5))]), | ||
round(percentage, 2), | ||
) | ||
|
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 progress_for_pyrogram
refactored with the following changes:
- Replace unused for index with underscore (
for-index-underscore
)
|
||
elif query.data == "helpcallback": | ||
await query.edit_message_text(text=Messages.HELP_TXT, reply_markup=Buttons.ME_GOIN_HOME) | ||
|
||
elif query.data == "aboutcallback": | ||
await query.edit_message_text(text=Messages.ABOUT_TXT, reply_markup=Buttons.ME_GOIN_HOME, disable_web_page_preview=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 unzipper_cb
refactored with the following changes:
- Hoist repeated code outside conditional statement (
hoist-statement-from-if
)
ext_out = ext_cmd.stdout.read()[:-1].decode("utf-8") | ||
return ext_out | ||
return ext_cmd.stdout.read()[:-1].decode("utf-8") |
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 __run_cmds_unzipper
refactored with the following changes:
- Inline variable that is immediately returned (
inline-immediately-returned-variable
)
if file_path == ".zst": | ||
os.mkdir(path) | ||
ex = await _extract_with_zstd(path, archive_path) | ||
return ex | ||
else: | ||
ex = await _extract_with_7z_helper(path, archive_path, password) | ||
return ex | ||
if file_path != ".zst": | ||
return await _extract_with_7z_helper(path, archive_path, password) | ||
os.mkdir(path) | ||
return await _extract_with_zstd(path, archive_path) |
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 extr_files
refactored with the following changes:
- Hoist repeated code outside conditional statement (
hoist-statement-from-if
) - Lift return into if (
lift-return-into-if
) - Swap if/else branches (
swap-if-else-branches
) - Remove unnecessary else after guard condition (
remove-unnecessary-else
)
num = 0 | ||
i_kbd = InlineKeyboard(row_width=1) | ||
data = [] | ||
data.append( | ||
InlineKeyboardButton(f"Upload All ♻️", f"ext_a|{user_id}|{chat_id}") | ||
) | ||
data = [InlineKeyboardButton('Upload All ♻️', f"ext_a|{user_id}|{chat_id}")] | ||
data.append( | ||
InlineKeyboardButton("Cancel ❌", "cancel_dis") | ||
) | ||
for file in paths: | ||
for num, file in enumerate(paths): | ||
data.append( | ||
InlineKeyboardButton(f"{num} - {os.path.basename(file)}", f"ext_f|{user_id}|{chat_id}|{num}") | ||
) | ||
num += 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 make_keyboard
refactored with the following changes:
- Move assignment closer to its usage within a block (
move-assign-in-block
) - Merge append into list declaration (
merge-list-append
) - Replace f-string with no interpolated values with string (
remove-redundant-fstring
) - Replace manual loop counter with call to enumerate (
convert-to-enumerate
)
Sourcery Code Quality Report❌ Merging this PR will decrease code quality in the affected files by 1.25%.
Here are some functions in these files that still need a tune-up:
Legend and ExplanationThe emojis denote the absolute quality of the code:
The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request. 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! Help us improve this quality report! |
Branch
main
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
main
branch, then run:Help us improve this pull request!