-
-
Notifications
You must be signed in to change notification settings - Fork 954
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 #12
Conversation
''.join(["●" for i in range(math.floor(percentage / 5))]), | ||
''.join(["○" for i in range(20 - math.floor(percentage / 5))]), | ||
round(percentage, 2)) | ||
''.join(["●" for _ in range(math.floor(percentage / 5))]), | ||
''.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 [×2] (
for-index-underscore
) - Replace call to format with f-string (
use-fstring-for-formatting
)
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
)
watermarked_file = output_file + ".watermark.png" | ||
watermarked_file = f"{output_file}.watermark.png" | ||
metadata = extractMetadata(createParser(input_file)) | ||
width = metadata.get("width") | ||
# https://stackoverflow.com/a/34547184/4723940 | ||
shrink_watermark_file_genertor_command = [ | ||
"ffmpeg", | ||
"-i", water_mark_file, | ||
"-i", | ||
water_mark_file, | ||
"-y -v quiet", | ||
"-vf", | ||
"scale={}*0.5:-1".format(width), | ||
watermarked_file | ||
f"scale={width}*0.5:-1", | ||
watermarked_file, | ||
] | ||
|
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 place_water_mark
refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation
) - Replace call to format with f-string (
use-fstring-for-formatting
)
if os.path.lexists(out_put_file_name): | ||
return out_put_file_name | ||
else: | ||
return None | ||
return out_put_file_name if os.path.lexists(out_put_file_name) 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 take_screen_shot
refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp
)
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.
✅
thumb_image_path = Config.DOWNLOAD_LOCATION + "/" + str(update.from_user.id) + ".jpg" | ||
thumb_image_path = f"{Config.DOWNLOAD_LOCATION}/{str(update.from_user.id)}.jpg" |
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 Gthumb01
refactored with the following changes:
- Use f-string instead of string concatenation [×3] (
use-fstring-for-concatenation
)
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.
✅
thumb_image_path = Config.DOWNLOAD_LOCATION + "/" + str(update.from_user.id) + ".jpg" | ||
thumb_image_path = f"{Config.DOWNLOAD_LOCATION}/{str(update.from_user.id)}.jpg" |
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 Gthumb02
refactored with the following changes:
- Use f-string instead of string concatenation [×3] (
use-fstring-for-concatenation
)
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.
✅
duration = 0 | ||
metadata = extractMetadata(createParser(download_directory)) | ||
if metadata is not None and metadata.has("duration"): | ||
duration = metadata.get('duration').seconds | ||
|
||
return duration | ||
return ( | ||
metadata.get('duration').seconds | ||
if metadata is not None and metadata.has("duration") | ||
else 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 Mdata03
refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp
) - Inline variable that is immediately returned (
inline-immediately-returned-variable
) - Move setting of default value for variable into
else
branch (introduce-default-else
) - Move assignment closer to its usage within a block (
move-assign-in-block
)
tmp_directory_for_each_user = Config.DOWNLOAD_LOCATION + "/" + str(update.from_user.id) | ||
tmp_directory_for_each_user = ( | ||
f"{Config.DOWNLOAD_LOCATION}/{str(update.from_user.id)}" | ||
) | ||
|
||
if not os.path.isdir(tmp_directory_for_each_user): | ||
os.makedirs(tmp_directory_for_each_user) | ||
download_directory = tmp_directory_for_each_user + "/" + custom_file_name | ||
download_directory = f"{tmp_directory_for_each_user}/{custom_file_name}" |
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 ddl_call_back
refactored with the following changes:
- Use f-string instead of string concatenation [×6] (
use-fstring-for-concatenation
)
save_ytdl_json_path = Config.DOWNLOAD_LOCATION + "/" + str(update.from_user.id) + ".json" | ||
save_ytdl_json_path = ( | ||
f"{Config.DOWNLOAD_LOCATION}/{str(update.from_user.id)}.json" | ||
) | ||
|
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 youtube_dl_call_back
refactored with the following changes:
- Use f-string instead of string concatenation [×10] (
use-fstring-for-concatenation
) - Simplify conditional into switch-like form [×10] (
switch
)
8d79df5
to
8d8aaf6
Compare
Sourcery Code Quality Report❌ Merging this PR will decrease code quality in the affected files by 0.66%.
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! |
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.
✅
if os.path.lexists(out_put_file_name): | ||
return out_put_file_name | ||
else: | ||
return None | ||
return out_put_file_name if os.path.lexists(out_put_file_name) 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.
✅
if os.path.lexists(out_put_file_name): | ||
return out_put_file_name | ||
else: | ||
return None | ||
return out_put_file_name if os.path.lexists(out_put_file_name) 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.
✅
ss_img = await place_water_mark(ss_img, output_directory + "/" + str(time.time()) + ".jpg", wf) | ||
ss_img = await place_water_mark( | ||
ss_img, f"{output_directory}/{str(time.time())}.jpg", wf | ||
) | ||
|
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.
✅
text="{}: {} of {}".format( | ||
ud_type, | ||
humanbytes(downloaded_size), | ||
humanbytes(total_size) | ||
) | ||
text=f"{ud_type}: {humanbytes(downloaded_size)} of {humanbytes(total_size)}", | ||
) | ||
|
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.
✅
broadcast_id = ''.join([random.choice(string.ascii_letters) for i in range(3)]) | ||
broadcast_id = ''.join([random.choice(string.ascii_letters) for _ in range(3)]) |
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.
✅
thumb_image_path = Config.DOWNLOAD_LOCATION + "/" + str(update.from_user.id) + ".jpg" | ||
thumb_image_path = f"{Config.DOWNLOAD_LOCATION}/{str(update.from_user.id)}.jpg" |
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.
✅
thumb_image_path = Config.DOWNLOAD_LOCATION + "/" + str(update.from_user.id) + ".jpg" | ||
thumb_image_path = f"{Config.DOWNLOAD_LOCATION}/{str(update.from_user.id)}.jpg" |
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.
✅
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!