Skip to content

Commit 6b73ae8

Browse files
committed
Fix 236 ruff lint errors blocking CI
- Add missing validate_path imports to 7 route files (F821) - Auto-fix import sorting across all route/core files (I001) - Remove unused imports (F401) - Prefix unused variables with underscore (F841)
1 parent 62362bf commit 6b73ae8

92 files changed

Lines changed: 165 additions & 225 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

opencut/core/ai_dubbing.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,14 @@
77
Supports 50+ languages via pluggable translation and TTS backends.
88
"""
99

10-
import json
1110
import logging
1211
import os
13-
import subprocess
1412
import tempfile
1513
from dataclasses import dataclass, field
1614
from typing import Callable, Dict, List, Optional, Tuple
1715

1816
from opencut.helpers import (
1917
FFmpegCmd,
20-
ensure_package,
21-
get_ffmpeg_path,
2218
get_video_info,
2319
output_path,
2420
run_ffmpeg,
@@ -216,7 +212,7 @@ def _generate_tts(
216212
# Try voice generation module
217213
try:
218214
from opencut.core.voice_gen import generate_voice
219-
result = generate_voice(
215+
generate_voice(
220216
text=text,
221217
output_path=output_audio,
222218
language=target_lang,
@@ -232,7 +228,7 @@ def _generate_tts(
232228
dur = max(1.0, target_duration)
233229
cmd = (FFmpegCmd()
234230
.option("f", "lavfi")
235-
.input(f"anullsrc=r=16000:cl=mono", t=str(dur))
231+
.input("anullsrc=r=16000:cl=mono", t=str(dur))
236232
.audio_codec("pcm_s16le")
237233
.output(output_audio)
238234
.build())

opencut/core/audio_anon.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,14 @@
99
advanced processing.
1010
"""
1111

12-
import json
1312
import logging
1413
import os
1514
import subprocess
1615
import tempfile
17-
from dataclasses import asdict, dataclass, field
18-
from typing import Callable, Dict, List, Optional
16+
from dataclasses import asdict, dataclass
17+
from typing import Callable, List, Optional
1918

20-
from opencut.helpers import get_ffmpeg_path, get_ffprobe_path, get_video_info, output_path, run_ffmpeg
19+
from opencut.helpers import get_ffmpeg_path, get_video_info, output_path, run_ffmpeg
2120

2221
logger = logging.getLogger("opencut")
2322

@@ -63,7 +62,6 @@ def _diarize_simple(input_path: str, num_speakers: int = 2) -> List[SpeakerSegme
6362
result = subprocess.run(cmd, capture_output=True, text=True, timeout=300, check=False)
6463

6564
segments = []
66-
speech_start = 0.0
6765
speaker_idx = 0
6866
current_start = 0.0
6967

@@ -142,7 +140,6 @@ def _pitch_shift_segment(
142140

143141
# Use asetrate + atempo for simple pitch shift
144142
# Raising pitch by semitones: rate_factor = 2^(semitones/12)
145-
import math
146143
rate_factor = 2 ** (semitones / 12.0)
147144
tempo_factor = 1.0 / rate_factor # compensate to keep duration
148145

@@ -270,7 +267,6 @@ def anonymize_speaker(
270267
try:
271268
# Create pitch-shifted version of full audio
272269
shifted_path = os.path.join(tmpdir, "shifted.wav")
273-
import math
274270
rate_factor = 2 ** (pitch_semitones / 12.0)
275271
tempo_factor = 1.0 / rate_factor
276272

opencut/core/auto_dub_pipeline.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ def _apply_lip_sync(
494494
_stage_progress(on_progress, STAGE_LIP_SYNC, 0, "Applying lip sync...")
495495

496496
try:
497-
from opencut.core.lip_sync_gen import apply_lip_sync, LipSyncConfig
497+
from opencut.core.lip_sync_gen import LipSyncConfig, apply_lip_sync
498498

499499
os.path.join(work_dir, "lip_synced.mp4")
500500
config = LipSyncConfig()

opencut/core/bg_replace_ai.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ class BGReplaceResult:
5353

5454
def _remove_bg_rembg(frame):
5555
"""Remove background from a single frame using rembg."""
56-
from rembg import remove
5756
import numpy as np
5857
from PIL import Image
58+
from rembg import remove
5959

6060
pil_img = Image.fromarray(frame[:, :, ::-1]) # BGR -> RGB
6161
result = remove(pil_img)
@@ -194,14 +194,13 @@ def replace_background(
194194
raise RuntimeError("opencv-python-headless is required")
195195

196196
import cv2
197-
import numpy as np
198197

199198
out = output_path_override or output_path(video_path, f"bg_{bg_type}")
200199

201200
if on_progress:
202201
on_progress(5, "Preparing background replacement...")
203202

204-
info = get_video_info(video_path)
203+
get_video_info(video_path)
205204

206205
# Determine removal method
207206
actual_removal = removal_method

opencut/core/broll_ai_gen.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,8 +405,8 @@ def _try_video_gen_api(prompt: str, config: BRollGenConfig,
405405
return None
406406

407407
try:
408-
import urllib.request
409408
import urllib.error
409+
import urllib.request
410410

411411
payload = {
412412
"prompt": _enhance_prompt(prompt, config.style_prompt_suffix),

opencut/core/chromatic_aberration.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,15 @@
1010
Uses FFmpeg's chromashift and scale filters.
1111
"""
1212

13-
import json
1413
import logging
15-
import math
1614
import os
1715
import subprocess
1816
import tempfile
19-
from dataclasses import dataclass, field
20-
from typing import Callable, Dict, List, Optional, Tuple
17+
from dataclasses import dataclass
18+
from typing import Callable, Optional, Tuple
2119

2220
from opencut.helpers import (
2321
FFmpegCmd,
24-
get_ffprobe_path,
2522
get_video_info,
2623
output_path,
2724
run_ffmpeg,

opencut/core/composition_guide.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@
1717
from opencut.helpers import (
1818
ensure_package,
1919
get_ffmpeg_path,
20-
get_ffprobe_path,
2120
get_video_info,
22-
output_path,
23-
run_ffmpeg,
2421
)
2522

2623
logger = logging.getLogger("opencut")

opencut/core/content_calendar.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import csv
99
import logging
1010
import os
11-
import re
1211
from dataclasses import dataclass, field
1312
from datetime import datetime, timedelta
1413
from typing import Callable, Dict, List, Optional
@@ -123,7 +122,7 @@ def _distribute_posts(
123122
# If items have no platform, distribute evenly
124123
unassigned = [it for it in items if not it.platform]
125124
if unassigned and platforms:
126-
per_platform = max(1, len(unassigned) // len(platforms))
125+
max(1, len(unassigned) // len(platforms))
127126
for i, item in enumerate(unassigned):
128127
p = platforms[i % len(platforms)]
129128
if p not in platform_queues:
@@ -219,7 +218,7 @@ def _export_ics(posts: List[ScheduledPost], output_path: str) -> str:
219218
f"SUMMARY:{summary}",
220219
f"DESCRIPTION:{description}",
221220
f"CATEGORIES:{post.platform.upper()}",
222-
f"STATUS:CONFIRMED",
221+
"STATUS:CONFIRMED",
223222
"END:VEVENT",
224223
])
225224

opencut/core/deinterlace.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
FFmpegCmd,
1919
get_ffmpeg_path,
2020
get_ffprobe_path,
21-
get_video_info,
2221
output_path,
2322
run_ffmpeg,
2423
)

opencut/core/delivery_validate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import re
1414
import subprocess as _sp
1515
from dataclasses import asdict, dataclass, field
16-
from typing import Callable, Dict, List, Optional, Any
16+
from typing import Any, Callable, Dict, List, Optional
1717

1818
from opencut.helpers import (
1919
get_ffmpeg_path,

0 commit comments

Comments
 (0)