refactor: remove unnecessary 'closing' usage for boto3 client (#9343)

This commit is contained in:
omr 2024-10-15 09:42:39 +09:00 committed by GitHub
commit 6d2c6caa23
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 24 additions and 36 deletions

View file

@ -2,7 +2,6 @@ import base64
import io
import json
from collections.abc import Generator
from contextlib import closing
from flask import Flask
from google.cloud import storage as google_cloud_storage
@ -43,7 +42,7 @@ class GoogleCloudStorage(BaseStorage):
def generate(filename: str = filename) -> Generator:
bucket = self.client.get_bucket(self.bucket_name)
blob = bucket.get_blob(filename)
with closing(blob.open(mode="rb")) as blob_stream:
with blob.open(mode="rb") as blob_stream:
while chunk := blob_stream.read(4096):
yield chunk