Skip to content

Commit afd0b0d

Browse files
committed
clean mypy
1 parent 3dafb93 commit afd0b0d

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
@@ -228,7 +228,8 @@ def image_blur_to_bytes_func(
228228
import base64
229229
import json
230230

231-
result_dict = {"status": "", "content": b""}
231+
status = ""
232+
content = b""
232233

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

256256
except Exception as e:
257-
result_dict["status"] = str(e)
257+
status = str(e)
258258

259259
if verbose:
260-
result_dict["content"] = base64.b64encode(result_dict["content"]).decode(
261-
"utf-8"
262-
)
263-
return json.dumps(result_dict)
260+
encoded_content = base64.b64encode(content).decode("utf-8")
261+
return json.dumps({"status": status, "content": encoded_content})
264262
else:
265-
return base64.b64encode(result_dict["content"]).decode("utf-8")
263+
return base64.b64encode(content).decode("utf-8")
266264

267265

268266
image_blur_to_bytes_def = FunctionDef(
@@ -350,7 +348,8 @@ def image_resize_to_bytes_func(
350348
import base64
351349
import json
352350

353-
result_dict = {"status": "", "content": b""}
351+
status = ""
352+
content = b""
354353

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

378376
except Exception as e:
379-
result_dict["status"] = str(e)
377+
status = str(e)
380378

381379
if verbose:
382-
result_dict["content"] = base64.b64encode(result_dict["content"]).decode(
383-
"utf-8"
384-
)
385-
return json.dumps(result_dict)
380+
encoded_content = base64.b64encode(content).decode("utf-8")
381+
return json.dumps({"status": status, "content": encoded_content})
386382
else:
387-
return base64.b64encode(result_dict["content"]).decode("utf-8")
383+
return base64.b64encode(content).decode("utf-8")
388384

389385

390386
image_resize_to_bytes_def = FunctionDef(

0 commit comments

Comments
 (0)