Skip to content

Commit

Permalink
style: apply
Browse files Browse the repository at this point in the history
  • Loading branch information
Dani Reinón committed Apr 28, 2022
1 parent 838af7c commit 688cfc7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
9 changes: 5 additions & 4 deletions storage3/_async/file_api.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
from dataclasses import dataclass, field
from pathlib import Path
from typing import Any, Optional, Union
Expand Down Expand Up @@ -65,8 +66,7 @@ def get_public_url(self, path: str) -> str:
file path, including the path and file name. For example `folder/image.png`.
"""
_path = self._get_final_path(path)
public_url = f"{self._url}/object/public/{_path}"
return public_url
return f"{self._url}/object/public/{_path}"

async def move(self, from_path: str, to_path: str) -> dict[str, str]:
"""
Expand Down Expand Up @@ -124,7 +124,7 @@ async def list(
extra_options = options or {}
body = dict(DEFAULT_SEARCH_OPTIONS, **extra_options)
extra_headers = {"Content-Type": "application/json"}
body["prefix"] = path if path else ""
body["prefix"] = path or ""
response = await self._request(
"POST",
f"{self._url}/object/list/{self.id}",
Expand Down Expand Up @@ -157,7 +157,8 @@ async def upload(
Parameters
----------
path
The relative file path including the bucket ID. Should be of the format `bucket/folder/subfolder/filename.png`. The bucket must already exist before attempting to upload.
The relative file path including the bucket ID. Should be of the format `bucket/folder/subfolder/filename.png`.
The bucket must already exist before attempting to upload.
file
The File object to be stored in the bucket. or a async generator of chunks
file_options
Expand Down
6 changes: 4 additions & 2 deletions storage3/_sync/bucket.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from httpx import HTTPError, Response

from ..types import RequestMethod
from ..utils import StorageException, SyncClient
from ..utils import SyncClient, StorageException
from .file_api import SyncBucket

__all__ = ["SyncStorageBucketAPI"]
Expand All @@ -25,7 +25,9 @@ def _request(
url: str,
json: Optional[dict[Any, Any]] = None,
) -> Response:
response = self._client.request(method, url, headers=self.headers, json=json)
response = self._client.request(
method, url, headers=self.headers, json=json
)
try:
response.raise_for_status()
except HTTPError:
Expand Down
11 changes: 6 additions & 5 deletions storage3/_sync/file_api.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import annotations
from dataclasses import dataclass, field
from pathlib import Path
from typing import Any, Optional, Union
Expand All @@ -6,7 +7,7 @@

from ..constants import DEFAULT_FILE_OPTIONS, DEFAULT_SEARCH_OPTIONS
from ..types import BaseBucket, ListBucketFilesOptions, RequestMethod
from ..utils import StorageException, SyncClient
from ..utils import SyncClient, StorageException

__all__ = ["SyncBucket"]

Expand Down Expand Up @@ -65,8 +66,7 @@ def get_public_url(self, path: str) -> str:
file path, including the path and file name. For example `folder/image.png`.
"""
_path = self._get_final_path(path)
public_url = f"{self._url}/object/public/{_path}"
return public_url
return f"{self._url}/object/public/{_path}"

def move(self, from_path: str, to_path: str) -> dict[str, str]:
"""
Expand Down Expand Up @@ -124,7 +124,7 @@ def list(
extra_options = options or {}
body = dict(DEFAULT_SEARCH_OPTIONS, **extra_options)
extra_headers = {"Content-Type": "application/json"}
body["prefix"] = path if path else ""
body["prefix"] = path or ""
response = self._request(
"POST",
f"{self._url}/object/list/{self.id}",
Expand Down Expand Up @@ -157,7 +157,8 @@ def upload(
Parameters
----------
path
The relative file path including the bucket ID. Should be of the format `bucket/folder/subfolder/filename.png`. The bucket must already exist before attempting to upload.
The relative file path including the bucket ID. Should be of the format `bucket/folder/subfolder/filename.png`.
The bucket must already exist before attempting to upload.
file
The File object to be stored in the bucket. or a async generator of chunks
file_options
Expand Down

0 comments on commit 688cfc7

Please sign in to comment.