-
Notifications
You must be signed in to change notification settings - Fork 53
Sourcery refactored main branch #4
base: main
Are you sure you want to change the base?
Conversation
if has_frame: | ||
return frame | ||
return None | ||
return frame if has_frame 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 get_video_frame
refactored with the following changes:
- Lift code into else after jump in control flow (
reintroduce-else
) - Replace if statement with if expression (
assign-if-exp
)
if platform.system().lower() == 'darwin': | ||
return 4 | ||
return 16 | ||
return 4 if platform.system().lower() == 'darwin' else 16 |
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 suggest_max_memory
refactored with the following changes:
- Lift code into else after jump in control flow (
reintroduce-else
) - Replace if statement with if expression (
assign-if-exp
)
if 'ROCMExecutionProvider' in roop.globals.execution_providers: | ||
return 1 | ||
return 8 | ||
return 1 if 'ROCMExecutionProvider' in roop.globals.execution_providers else 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 suggest_execution_threads
refactored with the following changes:
- Lift code into else after jump in control flow (
reintroduce-else
) - Replace if statement with if expression (
assign-if-exp
)
faces = get_many_faces(frame) | ||
if faces: | ||
if faces := get_many_faces(frame): |
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 get_one_face
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
)
commands = ['ffmpeg', '-hide_banner', '-hwaccel', 'auto', '-loglevel', roop.globals.log_level] | ||
commands.extend(args) | ||
commands = [ | ||
'ffmpeg', | ||
'-hide_banner', | ||
'-hwaccel', | ||
'auto', | ||
'-loglevel', | ||
roop.globals.log_level, | ||
*args, | ||
] |
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_ffmpeg
refactored with the following changes:
- Merge extend into list declaration (
merge-list-extend
)
return os.path.join(output_path, source_name + '-' + target_name + target_extension) | ||
return os.path.join( | ||
output_path, f'{source_name}-{target_name}{target_extension}' | ||
) |
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 normalize_output_path
refactored with the following changes:
- Use f-string instead of string concatenation [×3] (
use-fstring-for-concatenation
)
queues = [] | ||
for _ in range(queue_per_future): | ||
if not queue.empty(): | ||
queues.append(queue.get()) | ||
return queues | ||
return [queue.get() for _ in range(queue_per_future) if not queue.empty()] |
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 pick_queue
refactored with the following changes:
- Convert for loop into list comprehension (
list-comprehension
) - Inline variable that is immediately returned (
inline-immediately-returned-variable
)
many_faces = get_many_faces(temp_frame) | ||
if many_faces: | ||
if many_faces := get_many_faces(temp_frame): |
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 process_frame
refactored with the following changes:
- Use named expression to simplify assignment and conditional (
use-named-expression
)
many_faces = get_many_faces(temp_frame) | ||
if many_faces: | ||
if many_faces := get_many_faces(temp_frame): | ||
for target_face in many_faces: | ||
temp_frame = swap_face(source_face, target_face, temp_frame) | ||
else: | ||
target_face = get_one_face(temp_frame) | ||
if target_face: | ||
temp_frame = swap_face(source_face, target_face, temp_frame) | ||
elif target_face := get_one_face(temp_frame): | ||
temp_frame = swap_face(source_face, target_face, temp_frame) |
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 process_frame
refactored with the following changes:
- Merge else clause's nested if statement into elif (
merge-else-if-into-elif
) - Use named expression to simplify assignment and conditional [×2] (
use-named-expression
)
4bef5a7
to
65859df
Compare
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!