-
Notifications
You must be signed in to change notification settings - Fork 6
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
base: main
Are you sure you want to change the base?
Conversation
if stream_type in ("audio", "subtitle"): | ||
pass | ||
else: | ||
if stream_type not in ("audio", "subtitle"): |
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 download_file
refactored with the following changes:
- Swap if/else to remove empty if body (
remove-pass-body
)
if stream_type in ("audio", "subtitle"): | ||
pass | ||
else: | ||
if stream_type not in ("audio", "subtitle"): |
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 download_url_link
refactored with the following changes:
- Swap if/else to remove empty if body (
remove-pass-body
)
seconds, milliseconds = divmod(int(milliseconds), 1000) | ||
seconds, milliseconds = divmod(milliseconds, 1000) | ||
minutes, seconds = divmod(seconds, 60) | ||
hours, minutes = divmod(minutes, 60) | ||
days, hours = divmod(hours, 24) | ||
tmp = (((str(days) + "d, ") if days else "") + | ||
((str(hours) + "h, ") if hours else "") + | ||
((str(minutes) + "m, ") if minutes else "") + | ||
((str(seconds) + "s, ") if seconds else "") + | ||
((str(milliseconds) + "ms, ") if milliseconds else "")) | ||
tmp = ( | ||
(f"{str(days)}d, " if days else "") | ||
+ (f"{str(hours)}h, " if hours else "") | ||
+ (f"{str(minutes)}m, " if minutes else "") | ||
+ (f"{str(seconds)}s, " if seconds else "") | ||
+ (f"{str(milliseconds)}ms, " if milliseconds 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 time_formatter
refactored with the following changes:
- Remove unnecessary casts to int, str, float or bool (
remove-unnecessary-cast
) - Use f-string instead of string concatenation [×5] (
use-fstring-for-concatenation
)
if total_length < downloaded: | ||
total_length = downloaded | ||
total_length = max(total_length, downloaded) |
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 download_coroutine
refactored with the following changes:
- Replace comparison with min/max call (
min-max-identity
) - Replace multiple comparisons of same variable with
in
operator (merge-comparisons
)
return str(round(size, 2)) + " " + Dic_powerN[n] + 'B' | ||
return f"{str(round(size, 2))} {Dic_powerN[n]}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
)
seconds, milliseconds = divmod(int(milliseconds), 1000) | ||
seconds, milliseconds = divmod(milliseconds, 1000) | ||
minutes, seconds = divmod(seconds, 60) | ||
hours, minutes = divmod(minutes, 60) | ||
days, hours = divmod(hours, 24) | ||
tmp = ((str(days) + "d, ") if days else "") + \ | ||
((str(hours) + "h, ") if hours else "") + \ | ||
((str(minutes) + "m, ") if minutes else "") + \ | ||
((str(seconds) + "s, ") if seconds else "") + \ | ||
((str(milliseconds) + "ms, ") if milliseconds else "") | ||
tmp = ( | ||
(f"{str(days)}d, " if days else "") | ||
+ (f"{str(hours)}h, " if hours else "") | ||
+ (f"{str(minutes)}m, " if minutes else "") | ||
+ (f"{str(seconds)}s, " if seconds else "") | ||
+ (f"{str(milliseconds)}ms, " if milliseconds 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 TimeFormatter
refactored with the following changes:
- Remove unnecessary casts to int, str, float or bool (
remove-unnecessary-cast
) - Use f-string instead of string concatenation [×5] (
use-fstring-for-concatenation
)
title = None | ||
artist = None | ||
thumb = None | ||
duration = 0 | ||
|
||
metadata = extractMetadata(createParser(file_loc)) | ||
if metadata and metadata.has("title"): | ||
title = metadata.get("title") | ||
title = metadata.get("title") if metadata and metadata.has("title") 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 upload_audio
refactored with the following changes:
- Move assignment closer to its usage within a block (
move-assign-in-block
) - Replace if statement with if expression [×2] (
assign-if-exp
) - Replace multiple comparisons of same variable with
in
operator (merge-comparisons
) - Use f-string instead of string concatenation (
use-fstring-for-concatenation
) - Move setting of default value for variable into
else
branch (introduce-default-else
)
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!