Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions projects/singularity_cinema/compose_video/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,8 @@ def illustration_pos(t):
fg_clip = fg_clip.with_duration(duration)
current_video_clips.append(fg_clip)
if self.config.use_subtitle:
if duration is not None and i < len(subtitle_paths) and subtitle_paths[i]:
if duration is not None and i < len(
subtitle_paths) and subtitle_paths[i]:
Comment on lines +327 to +328
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

While this line break is syntactically correct, it harms readability by splitting the len() function call. According to PEP 8, the preferred way to wrap long lines is by using Python's implied line continuation inside parentheses. This approach is much cleaner and more readable.

Suggested change
if duration is not None and i < len(
subtitle_paths) and subtitle_paths[i]:
if (duration is not None and i < len(subtitle_paths)
and subtitle_paths[i]):
References
  1. PEP 8, the style guide for Python code, recommends using implied line continuation within parentheses for long lines to improve readability. The current formatting, which breaks a line inside a function call, is less clear than wrapping the entire conditional expression. (link)

segment_subs = subtitle_paths[i]
num_subs = len(segment_subs)
sub_duration = duration / num_subs
Expand All @@ -351,8 +352,7 @@ def illustration_pos(t):
current_video_clips.append(subtitle_clip)
except Exception as e:
logger.error(
f'Failed to load subtitle {sub_path}: {e}'
)
f'Failed to load subtitle {sub_path}: {e}')

# Add background as top layer (transparent PNG with decorative elements)
if background_path and os.path.exists(background_path):
Expand Down
Loading