Open
Conversation
| nextIndex = videos.index(currentVideo) + 1 | ||
| # If we're not wrapping around | ||
| if not nextIndex >= len(videos): | ||
| if nextIndex < len(videos): |
Author
There was a problem hiding this comment.
Function get_next_video refactored with the following changes:
- Simplify logical expression using De Morgan identities (
de-morgan)
| def get_random_video(viddir): | ||
| videos = list(filter(supported_filetype, os.listdir(viddir))) | ||
| if videos: | ||
| if videos := list(filter(supported_filetype, os.listdir(viddir))): |
Author
There was a problem hiding this comment.
Function get_random_video refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression)
Comment on lines
-189
to
+196
| output = f"{seconds:.1f} second(s) / {minutes:.1f} minute(s) / {hours:.1f} hour(s) / {days:.2f} day(s)" | ||
| return f"{seconds:.1f} second(s) / {minutes:.1f} minute(s) / {hours:.1f} hour(s) / {days:.2f} day(s)" | ||
| elif minutes < 1: | ||
| return f"{seconds:.1f} second(s)" | ||
| elif hours < 1: | ||
| return f"{minutes:.1f} minute(s)" | ||
| elif days < 1: | ||
| return f"{hours:.1f} hour(s)" | ||
| else: | ||
| if minutes < 1: | ||
| output = f"{seconds:.1f} second(s)" | ||
| elif hours < 1: | ||
| output = f"{minutes:.1f} minute(s)" | ||
| elif days < 1: | ||
| output = f"{hours:.1f} hour(s)" | ||
| else: | ||
| output = f"{days:.2f} day(s)" | ||
|
|
||
| return output | ||
| return f"{days:.2f} day(s)" |
Author
There was a problem hiding this comment.
Function estimate_runtime refactored with the following changes:
- Merge else clause's nested if statement into elif (
merge-else-if-into-elif) - Lift return into if (
lift-return-into-if)
Comment on lines
-207
to
+203
| for i in glob.glob(name + ".*"): | ||
| for i in glob.glob(f"{name}.*"): |
Author
There was a problem hiding this comment.
Function find_subtitles refactored with the following changes:
- Use f-string instead of string concatenation (
use-fstring-for-concatenation)
Comment on lines
-280
to
+276
| if args.directory: | ||
| viddir = args.directory | ||
| else: | ||
| viddir = "Videos" | ||
| viddir = args.directory if args.directory else "Videos" |
Author
There was a problem hiding this comment.
Lines 280-283 refactored with the following changes:
- Replace if statement with if expression (
assign-if-exp)
Comment on lines
+103
to
+107
| ruleCount = 8 | ||
|
|
||
| tab = ' ' | ||
| lineSpacing = 2 | ||
|
|
Author
There was a problem hiding this comment.
Lines 113-144 refactored with the following changes:
- Hoist statements out of for/while loops (
hoist-statement-from-loop) - Merge append into list declaration [×3] (
merge-list-append) - Use f-string instead of string concatenation [×3] (
use-fstring-for-concatenation)
|
|
||
| def clip(val, min_, max_): | ||
| return (min_ if val < min_ else (max_ if val > max_ else val)) | ||
| return min_ if val < min_ else min(val, max_) |
Author
There was a problem hiding this comment.
Function clip refactored with the following changes:
- Replace comparison with min/max call (
min-max-identity)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Branch
mainrefactored 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
mainbranch, then run:Help us improve this pull request!