-
Notifications
You must be signed in to change notification settings - Fork 64
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
Update to Pyro v2 (Sourcery refactored) #7
Conversation
Sourcery Code Quality Report❌ Merging this PR will decrease code quality in the affected files by 0.24%.
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! |
d16a4b3
to
67e643a
Compare
for path in glob.glob(os.path.join(DOWNLOAD_DIRECTORY, "*")): | ||
if path.endswith( | ||
( | ||
".avi", | ||
".mov", | ||
".flv", | ||
".wmv", | ||
".3gp", | ||
".mpeg", | ||
".webm", | ||
".mp4", | ||
".mkv", | ||
return next( | ||
( | ||
(True, path) | ||
for path in glob.glob(os.path.join(DOWNLOAD_DIRECTORY, "*")) | ||
if path.endswith( | ||
( | ||
".avi", | ||
".mov", | ||
".flv", | ||
".wmv", | ||
".3gp", | ||
".mpeg", | ||
".webm", | ||
".mp4", | ||
".mkv", | ||
) | ||
) | ||
) and path.startswith(ytdl.prepare_filename(meta)): | ||
return True, path | ||
return False, "Something went wrong! No video file exists on server." | ||
and path.startswith(ytdl.prepare_filename(meta)) | ||
), | ||
(False, "Something went wrong! No video file exists on server."), | ||
) |
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 utube_dl
refactored with the following changes:
- Use the built-in function
next
instead of a for-loop (use-next
)
return str(round(size, 2)) + " " + dict_power_n[number] + "B" | ||
return f"{str(round(size, 2))} {dict_power_n[number]}B" |
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 humanbytes
refactored with the following changes:
- Use f-string instead of string concatenation [×3] (
use-fstring-for-concatenation
)
return res.group(5) | ||
return res[5] |
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 GoogleDrive.getIdFromUrl
refactored with the following changes:
- Replace m.group(x) with m[x] for re.Match objects (
use-getitem-for-re-match-groups
)
for file in response.get("files", []): | ||
files.append(file) | ||
files.extend(iter(response.get("files", []))) |
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 GoogleDrive.getFilesByFolderId
refactored with the following changes:
- Replace a for append loop with list extend (
for-append-to-extend
) - Simplify generator expression (
simplify-generator
)
saved_cred = SESSION.query(gDriveCreds).get(chat_id) | ||
if saved_cred: | ||
if saved_cred := SESSION.query(gDriveCreds).get(chat_id): |
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 _clear
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
)
rem = SESSION.query(ParentID).get(chat_id) | ||
if rem: | ||
if rem := SESSION.query(ParentID).get(chat_id): |
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 _clear
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
)
user_id = message.from_user.id | ||
if len(message.command) > 1: | ||
link = message.command[1] | ||
user_id = message.from_user.id |
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 _clone
refactored with the following changes:
- Move assignments closer to their usage (
move-assign
)
@@ -16,7 +16,6 @@ | |||
& CustomFilters.auth_users | |||
) | |||
def _delete(client: Client, message: Message): | |||
user_id = message.from_user.id |
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 _delete
refactored with the following changes:
- Move assignments closer to their usage (
move-assign
) - Split conditional into multiple branches (
split-or-ifs
) - Merge duplicate blocks in conditional (
merge-duplicate-blocks
) - Remove redundant conditional (
remove-redundant-if
)
user_id = message.from_user.id | ||
if len(message.command) > 1: | ||
sent_message = message.reply_text("🕵️**Checking Link...**", quote=True) | ||
link = message.command[1] | ||
user_id = message.from_user.id |
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 _ytdl
refactored with the following changes:
- Move assignments closer to their usage (
move-assign
)
Pull Request #6 refactored by Sourcery.
If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.
NOTE: As code is pushed to the original Pull Request, Sourcery will
re-run and update (force-push) this Pull Request with new refactorings as
necessary. If Sourcery finds no refactorings at any point, this Pull Request
will be closed automatically.
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
Pyro-v2
branch, then run:Help us improve this pull request!