From 94988d6ac822dcf832f8b2ee820af3f75ecdf85b Mon Sep 17 00:00:00 2001 From: Ismael Date: Fri, 24 Feb 2023 10:47:18 -0500 Subject: [PATCH] lint --- .pre-commit-config.yaml | 1 - Makefile | 2 +- guillotina_gcloudstorage/storage.py | 29 ++++++++++++++++++++++------- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e88628d..539e4e1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,5 @@ repos: - repo: https://github.com/ambv/black - rev: 19.10b0 hooks: - id: black language_version: python3.7 diff --git a/Makefile b/Makefile index 5472d7b..b62e6a5 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ pre-checks: pre-checks-deps mypy -p guillotina_gcloudstorage --ignore-missing-imports lint-deps: - pip install "isort>=4,<5" black==19.10b0 + pip install "isort>=4,<5" black lint: black guillotina_gcloudstorage diff --git a/guillotina_gcloudstorage/storage.py b/guillotina_gcloudstorage/storage.py index 9429797..ebd993d 100644 --- a/guillotina_gcloudstorage/storage.py +++ b/guillotina_gcloudstorage/storage.py @@ -201,7 +201,11 @@ async def start(self, dm): "Content-Length": str(call_size), } ) - async with util.session.post(init_url, headers=headers, data=metadata,) as call: + async with util.session.post( + init_url, + headers=headers, + data=metadata, + ) as call: if call.status != 200: text = await call.text() raise GoogleCloudException(f"{call.status}: {text}") @@ -326,7 +330,10 @@ async def exists(self): OBJECT_BASE_URL, await util.get_bucket_name(), quote_plus(file.uri) ) - async with util.session.get(url, headers=await self.get_headers(),) as api_resp: + async with util.session.get( + url, + headers=await self.get_headers(), + ) as api_resp: return api_resp.status == 200 @backoff.on_exception(backoff.expo, RETRIABLE_EXCEPTIONS, max_tries=4) @@ -351,7 +358,10 @@ async def copy(self, to_storage_manager, to_dm): headers = await self.get_headers() headers.update({"Content-Type": "application/json"}) - async with util.session.post(url, headers=headers,) as resp: + async with util.session.post( + url, + headers=headers, + ) as resp: if resp.status == 404: text = await resp.text() reason = ( @@ -446,10 +456,11 @@ async def get_access_token(self): def get_client(self): if self._client is None: - if self._json_credentials: - self._client = google.cloud.storage.Client.from_service_account_json( # noqa - self._json_credentials + self._client = ( + google.cloud.storage.Client.from_service_account_json( # noqa + self._json_credentials + ) ) else: self._client = google.cloud.storage.Client() @@ -570,7 +581,11 @@ async def iterate_bucket_page(self, page_token=None, prefix=None): if access_token: headers = {"AUTHORIZATION": f"Bearer {access_token}"} - async with self.session.get(url, headers=headers, params=params,) as resp: + async with self.session.get( + url, + headers=headers, + params=params, + ) as resp: assert resp.status == 200 data = await resp.json() return data