Skip to content

Commit 44ac399

Browse files
committed
Switch to uv and ruff
1 parent 779e78a commit 44ac399

File tree

115 files changed

+1259
-445
lines changed

Some content is hidden

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

115 files changed

+1259
-445
lines changed

.github/workflows/test.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ jobs:
1414
with:
1515
python-version: "3.12"
1616

17-
- run: pip install black==24.8.0
18-
- run: python -m black --check .
17+
- run: pip install ruff==0.12
18+
- run: python -m ruff check
1919

2020
test:
2121
runs-on: ubuntu-24.04

.pre-commit-config.yaml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.6.0
3+
rev: v5.0.0
44
hooks:
55
- id: mixed-line-ending
66
- id: trailing-whitespace
@@ -22,10 +22,16 @@ repos:
2222
- id: check-toml
2323
- id: detect-private-key
2424
- id: end-of-file-fixer
25-
- repo: https://github.com/psf/black
26-
rev: 24.8.0
25+
- repo: https://github.com/astral-sh/ruff-pre-commit
26+
# Ruff version.
27+
rev: v0.12.1
2728
hooks:
28-
- id: black
29+
# Run the linter.
30+
- id: ruff-check
31+
args: [ --fix ]
32+
# Run the formatter.
33+
- id: ruff-format
34+
2935
# - repo: https://github.com/pre-commit/mirrors-mypy
3036
# rev: 'v0.942'
3137
# hooks:

fastflix/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def start_fastflix():
1010
exit_code = 2
1111
portable_mode = True
1212
try:
13-
from fastflix import portable
13+
from fastflix import portable # noqa: F401
1414
except ImportError:
1515
portable_mode = False
1616

fastflix/application.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ def app_setup(
246246
try:
247247
ProgressBar(app, startup_tasks)
248248
except Exception:
249-
logger.exception(f'{t("Could not start FastFlix")}!')
249+
logger.exception(f"{t('Could not start FastFlix')}!")
250250
sys.exit(1)
251251

252252
container = Container(app)

fastflix/encoders/av1_aom/command_builder.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# -*- coding: utf-8 -*-
2-
import re
32
import secrets
43

54
from fastflix.encoders.common.helpers import Command, generate_all, generate_color_details, null
@@ -21,7 +20,7 @@ def build(fastflix: FastFlix):
2120
)
2221

2322
if settings.row_mt.lower() == "enabled":
24-
beginning += f"-row-mt 1 "
23+
beginning += "-row-mt 1 "
2524

2625
if settings.bitrate:
2726
pass_log_file = fastflix.current_video.work_path / f"pass_log_file_{secrets.token_hex(10)}"

fastflix/encoders/av1_aom/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
video_extensions = [".mkv", ".mp4", ".ts", ".mov", ".webm", ".avi", ".mts", ".m2ts", ".m4v"]
1010
video_dimension_divisor = 8
1111

12-
ref = importlib.resources.files("fastflix") / f"data/encoders/icon_av1_aom.png"
12+
ref = importlib.resources.files("fastflix") / "data/encoders/icon_av1_aom.png"
1313
with importlib.resources.as_file(ref) as icon_file:
1414
icon = str(icon_file.resolve())
1515

@@ -18,5 +18,5 @@
1818
enable_attachments = True
1919
enable_concat = True
2020

21-
from fastflix.encoders.av1_aom.command_builder import build
22-
from fastflix.encoders.av1_aom.settings_panel import AV1 as settings_panel
21+
from fastflix.encoders.av1_aom.command_builder import build # noqa: F401,E402
22+
from fastflix.encoders.av1_aom.settings_panel import AV1 as settings_panel # noqa: F401,E402

fastflix/encoders/avc_x264/command_builder.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# -*- coding: utf-8 -*-
2-
import re
32
import secrets
43

54
from fastflix.encoders.common.helpers import Command, generate_all, generate_color_details, null
@@ -12,7 +11,7 @@ def build(fastflix: FastFlix):
1211

1312
beginning, ending, output_fps = generate_all(fastflix, "libx264")
1413

15-
beginning += f'{f"-tune:v {settings.tune}" if settings.tune else ""} {generate_color_details(fastflix)} '
14+
beginning += f"{f'-tune:v {settings.tune}' if settings.tune else ''} {generate_color_details(fastflix)} "
1615

1716
if settings.profile and settings.profile != "default":
1817
beginning += f"-profile:v {settings.profile} "
@@ -38,7 +37,7 @@ def build(fastflix: FastFlix):
3837
return [Command(command=command, name="Single pass bitrate", exe="ffmpeg")]
3938

4039
elif settings.crf:
41-
command = f"{beginning} -crf:v {settings.crf} " f"-preset:v {settings.preset} {settings.extra} {ending}"
40+
command = f"{beginning} -crf:v {settings.crf} -preset:v {settings.preset} {settings.extra} {ending}"
4241
return [Command(command=command, name="Single pass CRF", exe="ffmpeg")]
4342

4443
else:

fastflix/encoders/avc_x264/main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
video_extensions = [".mkv", ".mp4", ".ts", ".mov", ".avi", ".mts", ".m2ts", ".m4v"]
1010
video_dimension_divisor = 1
1111

12-
ref = importlib.resources.files("fastflix") / f"data/encoders/icon_x264.png"
12+
ref = importlib.resources.files("fastflix") / "data/encoders/icon_x264.png"
1313
with importlib.resources.as_file(ref) as icon_file:
1414
icon = str(icon_file.resolve())
1515

@@ -18,5 +18,5 @@
1818
enable_attachments = True
1919
enable_concat = True
2020

21-
from fastflix.encoders.avc_x264.command_builder import build
22-
from fastflix.encoders.avc_x264.settings_panel import AVC as settings_panel
21+
from fastflix.encoders.avc_x264.command_builder import build # noqa: F401,E402
22+
from fastflix.encoders.avc_x264.settings_panel import AVC as settings_panel # noqa: F401,E402

fastflix/encoders/common/helpers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def generate_ffmpeg_start(
5050
start_extra: str = "",
5151
**_,
5252
) -> str:
53-
time_settings = f'{f"-ss {start_time}" if start_time else ""} {f"-to {end_time}" if end_time else ""}'.strip()
53+
time_settings = f"{f'-ss {start_time}' if start_time else ''} {f'-to {end_time}' if end_time else ''}".strip()
5454
time_one = time_settings if fast_seek else ""
5555
time_two = time_settings if not fast_seek else ""
5656
incoming_fps = f"-r {source_fps}" if source_fps else ""
@@ -232,7 +232,7 @@ def generate_filters(
232232
f"format=p010,hwupload,tonemap_opencl=tonemap={tone_map}:desat=0:r=tv:p=bt709:t=bt709:m=bt709:format=nv12,hwdownload,format=nv12"
233233
)
234234
elif vaapi:
235-
filter_list.append(f"tonemap_vaapi=format=nv12:p=bt709:t=bt709:m=bt709")
235+
filter_list.append("tonemap_vaapi=format=nv12:p=bt709:t=bt709:m=bt709")
236236
else:
237237
filter_list.append(
238238
f"zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap={tone_map}:desat=0,zscale=t=bt709:m=bt709:r=tv,format=yuv420p"

fastflix/encoders/common/setting_panel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ def _add_custom(self, title="Custom ffmpeg options", connect="default", disable_
269269
if connect and connect != "default":
270270
self.ffmpeg_extras_widget.disconnect()
271271
if connect == "self":
272-
connect = lambda: self.page_update()
272+
connect = lambda: self.page_update() # noqa: E731
273273
self.ffmpeg_extras_widget.textChanged.connect(connect)
274274
self.widgets["extra_both_passes"].toggled.connect(connect)
275275
else:

0 commit comments

Comments
 (0)