Skip to content

Commit e505e2f

Browse files
committed
clean mypy
1 parent da9a681 commit e505e2f

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed

bigframes/blob/_functions.py

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,8 @@ def image_blur_to_bytes_func(
229229
import base64
230230
import json
231231

232-
result_dict = {"status": "", "content": b""}
232+
status = ""
233+
content = b""
233234

234235
try:
235236
import cv2 as cv # type: ignore
@@ -251,19 +252,16 @@ def image_blur_to_bytes_func(
251252
nparr = np.frombuffer(bts, np.uint8)
252253
img = cv.imdecode(nparr, cv.IMREAD_UNCHANGED)
253254
img_blurred = cv.blur(img, ksize=(ksize_x, ksize_y))
254-
bts = cv.imencode(ext, img_blurred)[1].tobytes()
255-
result_dict["content"] = bts
255+
content = cv.imencode(ext, img_blurred)[1].tobytes()
256256

257257
except Exception as e:
258-
result_dict["status"] = str(e)
258+
status = str(e)
259259

260260
if verbose:
261-
result_dict["content"] = base64.b64encode(result_dict["content"]).decode(
262-
"utf-8"
263-
)
264-
return json.dumps(result_dict)
261+
encoded_content = base64.b64encode(content).decode("utf-8")
262+
return json.dumps({"status": status, "content": encoded_content})
265263
else:
266-
return base64.b64encode(result_dict["content"]).decode("utf-8")
264+
return base64.b64encode(content).decode("utf-8")
267265

268266

269267
image_blur_to_bytes_def = FunctionDef(
@@ -351,7 +349,8 @@ def image_resize_to_bytes_func(
351349
import base64
352350
import json
353351

354-
result_dict = {"status": "", "content": b""}
352+
status = ""
353+
content = b""
355354

356355
try:
357356
import cv2 as cv # type: ignore
@@ -373,19 +372,16 @@ def image_resize_to_bytes_func(
373372
nparr = np.frombuffer(bts, np.uint8)
374373
img = cv.imdecode(nparr, cv.IMREAD_UNCHANGED)
375374
img_resized = cv.resize(img, dsize=(dsize_x, dsize_y), fx=fx, fy=fy)
376-
bts = cv.imencode(".jpeg", img_resized)[1].tobytes()
377-
result_dict["content"] = bts
375+
content = cv.imencode(".jpeg", img_resized)[1].tobytes()
378376

379377
except Exception as e:
380-
result_dict["status"] = str(e)
378+
status = str(e)
381379

382380
if verbose:
383-
result_dict["content"] = base64.b64encode(result_dict["content"]).decode(
384-
"utf-8"
385-
)
386-
return json.dumps(result_dict)
381+
encoded_content = base64.b64encode(content).decode("utf-8")
382+
return json.dumps({"status": status, "content": encoded_content})
387383
else:
388-
return base64.b64encode(result_dict["content"]).decode("utf-8")
384+
return base64.b64encode(content).decode("utf-8")
389385

390386

391387
image_resize_to_bytes_def = FunctionDef(

0 commit comments

Comments
 (0)