Skip to content

Commit 1646188

Browse files
committed
refactor(transcode)!: overwrite arg of transcode func is keyword only
Forcing keyword only increases readability.
1 parent 0179528 commit 1646188

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

moe/plugins/transcode/transcode_core.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ def transcode(
4747
item: I,
4848
to_format: TranscodeFormat,
4949
out_path: Path | None = None,
50-
overwrite: bool = False, # noqa: FBT001, FBT002
50+
*,
51+
overwrite: bool = False,
5152
) -> I:
5253
"""Transcodes a track or album to a specific format.
5354
@@ -69,15 +70,16 @@ def transcode(
6970
out_path = out_path or fmt_item_path(item, transcode_path)
7071

7172
if isinstance(item, Album):
72-
return _transcode_album(item, to_format, out_path, overwrite)
73-
return _transcode_track(item, to_format, out_path, overwrite)
73+
return _transcode_album(item, to_format, out_path, overwrite=overwrite)
74+
return _transcode_track(item, to_format, out_path, overwrite=overwrite)
7475

7576

7677
def _transcode_album(
7778
album: Album,
7879
to_format: TranscodeFormat,
7980
out_path: Path,
80-
overwrite: bool = False, # noqa: FBT001, FBT002
81+
*,
82+
overwrite: bool = False,
8183
) -> Album:
8284
"""Transcodes an album to a specific format.
8385
@@ -130,7 +132,8 @@ def _transcode_track(
130132
track: Track,
131133
to_format: TranscodeFormat,
132134
out_path: Path,
133-
overwrite: bool = False, # noqa: FBT001, FBT002
135+
*,
136+
overwrite: bool = False,
134137
) -> Track:
135138
"""Transcodes a track to a specific format.
136139
@@ -161,7 +164,7 @@ def _transcode_track(
161164
out_path.parent.mkdir(parents=True, exist_ok=True)
162165
out_path = out_path.with_suffix(".mp3")
163166

164-
_transcode_path(track.path, to_format, out_path, overwrite)
167+
_transcode_path(track.path, to_format, out_path, overwrite=overwrite)
165168

166169
transcoded_track = Track.from_file(out_path)
167170
log.info(f"Transcoded track. [{transcoded_track=!r}]")
@@ -173,7 +176,7 @@ def _transcode_path(
173176
path: Path,
174177
to_format: TranscodeFormat,
175178
out_path: Path,
176-
overwrite: bool = False, # noqa: FBT001, FBT002
179+
overwrite: bool = False, # noqa: FBT001, FBT002 starmap restricts keyword args
177180
) -> None:
178181
"""Transcodes a file to `to_format`.
179182

0 commit comments

Comments
 (0)