Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
gitcarbs committed Feb 24, 2023
1 parent 1d39123 commit 94988d6
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
repos:
- repo: https://github.com/ambv/black
rev: 19.10b0
hooks:
- id: black
language_version: python3.7
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 22 additions & 7 deletions guillotina_gcloudstorage/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down Expand Up @@ -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)
Expand All @@ -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 = (
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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

0 comments on commit 94988d6

Please sign in to comment.