|
20 | 20 |
|
21 | 21 |
|
22 | 22 | class FsProvider(ABC): |
23 | | - def __init__(self, storage_options: dict[str, Any] | None = {}): |
| 23 | + def __init__(self, storage_options: dict[str, Any] | None = None): |
| 24 | + if storage_options is None: |
| 25 | + storage_options = {} |
24 | 26 | self.storage_options = storage_options |
25 | 27 |
|
26 | 28 | @abstractmethod |
@@ -50,7 +52,7 @@ def is_empty(self, path: str) -> bool: |
50 | 52 |
|
51 | 53 |
|
52 | 54 | class GCPFsProvider(FsProvider): |
53 | | - def __init__(self, storage_options: dict[str, Any] | None = {}): |
| 55 | + def __init__(self, storage_options: dict[str, Any] | None = None): |
54 | 56 | if not _GOOGLE_STORAGE_AVAILABLE: |
55 | 57 | raise ModuleNotFoundError(str(_GOOGLE_STORAGE_AVAILABLE)) |
56 | 58 | from google.cloud import storage |
@@ -133,9 +135,9 @@ def is_empty(self, path: str) -> bool: |
133 | 135 |
|
134 | 136 |
|
135 | 137 | class S3FsProvider(FsProvider): |
136 | | - def __init__(self, storage_options: dict[str, Any] | None = {}): |
| 138 | + def __init__(self, storage_options: dict[str, Any] | None = None): |
137 | 139 | super().__init__(storage_options=storage_options) |
138 | | - self.client = S3Client(storage_options=storage_options) |
| 140 | + self.client = S3Client(storage_options=self.storage_options) |
139 | 141 |
|
140 | 142 | def upload_file(self, local_path: str, remote_path: str) -> None: |
141 | 143 | bucket_name, blob_path = get_bucket_and_path(remote_path, "s3") |
@@ -225,11 +227,11 @@ def is_empty(self, path: str) -> bool: |
225 | 227 |
|
226 | 228 |
|
227 | 229 | class R2FsProvider(S3FsProvider): |
228 | | - def __init__(self, storage_options: dict[str, Any] | None = {}): |
| 230 | + def __init__(self, storage_options: dict[str, Any] | None = None): |
229 | 231 | super().__init__(storage_options=storage_options) |
230 | 232 |
|
231 | 233 | # Create R2Client with refreshable credentials |
232 | | - self.client = R2Client(storage_options=storage_options) |
| 234 | + self.client = R2Client(storage_options=self.storage_options) |
233 | 235 |
|
234 | 236 | def upload_file(self, local_path: str, remote_path: str) -> None: |
235 | 237 | bucket_name, blob_path = get_bucket_and_path(remote_path, "r2") |
@@ -324,7 +326,7 @@ def get_bucket_and_path(remote_filepath: str, expected_scheme: str = "s3") -> tu |
324 | 326 | return bucket_name, blob_path |
325 | 327 |
|
326 | 328 |
|
327 | | -def _get_fs_provider(remote_filepath: str, storage_options: dict[str, Any] | None = {}) -> FsProvider: |
| 329 | +def _get_fs_provider(remote_filepath: str, storage_options: dict[str, Any] | None = None) -> FsProvider: |
328 | 330 | obj = parse.urlparse(remote_filepath) |
329 | 331 | if obj.scheme == "gs": |
330 | 332 | return GCPFsProvider(storage_options=storage_options) |
|
0 commit comments