Skip to content

Commit 1c77b7f

Browse files
[Style] Remove unnecessary **kwargs in Media._convert() -- finally!
1 parent 369b5c9 commit 1c77b7f

5 files changed

Lines changed: 16 additions & 17 deletions

File tree

GkmasObjectManager/adv/adventure.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def _get_commands(self) -> list[dict]:
2828
]
2929
return self.commands
3030

31-
def _convert(self, raw: bytes, **kwargs) -> bytes:
31+
def _convert(self, raw: bytes) -> bytes:
3232
# only for compatibility with GkmasResource
3333
return bytes(
3434
json.dumps(

GkmasObjectManager/media/audio.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def _init_mimetype(self):
2828
self.mimetype = "audio"
2929
self.raw_format = self._name_ext
3030

31-
def _convert(self, raw: bytes, **kwargs) -> bytes:
31+
def _convert(self, raw: bytes) -> bytes:
3232
audio = AudioSegment.from_file(BytesIO(raw))
3333
return audio.export(format=self.converted_format).read()
3434

@@ -40,7 +40,7 @@ def _init_mimetype(self):
4040
self.mimetype = "audio"
4141
self.default_converted_format = "wav"
4242

43-
def _convert(self, raw: bytes, **kwargs) -> bytes:
43+
def _convert(self, raw: bytes) -> bytes:
4444
env = UnityPy.load(raw)
4545
values = list(env.container.values())
4646
assert len(values) == 1, f"{self.name} contains {len(values)} audio clips."
@@ -65,7 +65,7 @@ def _make_vgmstream_args(self, tmp_in: str, tmp_out: str, suffix: str) -> list:
6565
tmp_in,
6666
]
6767

68-
def _convert(self, raw: bytes, **kwargs) -> bytes:
68+
def _convert(self, raw: bytes) -> bytes:
6969
# uses pydub in vastly different ways,
7070
# thus this class is not inherited from GkmasAudio
7171

GkmasObjectManager/media/dummy.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ def __init__(self, name: str, downloader: Callable[[], dict]):
6262
# but about *correctness* where the same format with a different
6363
# image_resize wouldn't even trigger _convert() otherwise.
6464
# This is of type Union[None, str, Tuple[int, int]],
65-
# which used to be a global const, but was soon deprecated since
66-
# inside Image we use kwargs.get(), where we can't enforce type hint.
65+
# which used to be a global const, but was soon deprecated
66+
# since we use kwargs.get() and can't enforce type hint.
6767
# On the other hand, we can't record the sanitized "new size" tuple here,
6868
# since it's about checking cache against user input *before* conversion,
6969
# and we don't want to move _determine_new_size() to this class.
@@ -75,7 +75,7 @@ def _init_mimetype(self):
7575
self.default_converted_format = "" # TO BE OVERRIDDEN (choose one)
7676
# yeah these two lines appear twice... this time just as a hint
7777

78-
def _convert(self, raw: bytes, **kwargs) -> bytes:
78+
def _convert(self, raw: bytes) -> bytes:
7979
raise NotImplementedError # TO BE OVERRIDDEN
8080

8181
def get_data(self, **kwargs) -> dict:
@@ -119,7 +119,7 @@ def get_data(self, **kwargs) -> dict:
119119
self.converted = None # invalidate cache
120120
self.image_resize = image_resize
121121

122-
_bytes = self._get_converted(**kwargs)
122+
_bytes = self._get_converted()
123123
return {
124124
"bytes": _bytes,
125125
"mimetype": (
@@ -165,10 +165,10 @@ def _get_raw(self) -> bytes:
165165
self.raw = data["bytes"]
166166
return data["bytes"] # cached or not, this is "valid"
167167

168-
def _get_converted(self, **kwargs) -> bytes:
168+
def _get_converted(self) -> bytes:
169169
if self.converted is not None:
170170
return self.converted # assumes proper invalidation beforehand
171-
converted = self._convert(self._get_raw(), **kwargs) # e.g., image_resize
171+
converted = self._convert(self._get_raw())
172172
if self.ENABLE_CACHE:
173173
self.converted = converted
174174
return converted

GkmasObjectManager/media/image.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,10 @@ def _init_mimetype(self):
2323
self.mimetype = "image"
2424
self.raw_format = self._name_ext
2525

26-
def _convert(self, raw: bytes, **kwargs) -> bytes:
27-
return self._img2bytes(Image.open(BytesIO(raw)), **kwargs)
26+
def _convert(self, raw: bytes) -> bytes:
27+
return self._img2bytes(Image.open(BytesIO(raw)))
2828

29-
# don't put 'image_resize' in signature to match the parent class
30-
def _img2bytes(self, img: Image, **kwargs) -> bytes:
29+
def _img2bytes(self, img: Image) -> bytes:
3130

3231
image_resize = self.image_resize
3332
if image_resize:
@@ -108,8 +107,8 @@ def _init_mimetype(self):
108107
self.mimetype = "image"
109108
self.default_converted_format = "png"
110109

111-
def _convert(self, raw: bytes, **kwargs) -> bytes:
110+
def _convert(self, raw: bytes) -> bytes:
112111
env = UnityPy.load(raw)
113112
values = list(env.container.values())
114113
assert len(values) == 1, f"{self.name} contains {len(values)} images."
115-
return super()._img2bytes(values[0].read().image, **kwargs)
114+
return super()._img2bytes(values[0].read().image)

GkmasObjectManager/media/video.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def _init_mimetype(self):
1818
self.mimetype = "video"
1919
self.default_converted_format = "mp4"
2020

21-
def _convert(self, raw: bytes, **kwargs) -> bytes:
21+
def _convert(self, raw: bytes) -> bytes:
2222

2323
stream_in = ffmpeg.input("pipe:0")
2424
stream_out = ffmpeg.output(

0 commit comments

Comments
 (0)