Skip to content

Commit 27d0e3a

Browse files
authored
Merge pull request #15 from JJ11teen/dev
Wrapper arg fix
2 parents ea53eb6 + 73066af commit 27d0e3a

File tree

3 files changed

+20
-8
lines changed

3 files changed

+20
-8
lines changed

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = cloud-mappings
3-
version = 1.2.0
3+
version = 1.2.1
44
author = Lucas Sargent
55
author_email = lucas.sargent@outlook.com
66
description = MutableMapping interfaces for common cloud storage providers

src/cloudmappings/wrappers.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1+
import inspect
2+
13
from .cloudstoragemapping import CloudMapping
24

35

46
def _parse_cloud_mapping_kwargs(kwargs: dict):
5-
cloud_mapping_kwargs = dict(
6-
sync_initially=kwargs.pop("sync_initially", True),
7-
read_blindly=kwargs.pop("read_blindly", False),
8-
read_blindly_default=kwargs.pop("read_blindly_default", None),
9-
ordered_dumps_funcs=kwargs.pop("ordered_dumps_funcs", None),
10-
ordered_loads_funcs=kwargs.pop("ordered_loads_funcs", None),
11-
)
7+
# We inspect the CloudMapping.__init__ function to determine what kwargs
8+
# it understands, and pull those out. The remaining kwargs are then passed
9+
# to the storage provider.
10+
cloud_mapping_kwargs = {
11+
n: kwargs.pop(n) if n in kwargs else p.default
12+
for n, p in inspect.signature(CloudMapping.__init__).parameters.items()
13+
if n not in ["self", "storage_provider"]
14+
}
15+
print(cloud_mapping_kwargs)
1216
return cloud_mapping_kwargs, kwargs
1317

1418

tests/tests/5_wrappers.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ def test_azure_blob_mapping(self, azure_blob_storage_account_url, test_container
1313
container_name=test_container_name,
1414
sync_initially=False,
1515
read_blindly=True,
16+
read_blindly_error=False,
17+
read_blindly_default=None,
1618
)
1719
assert len(cm.etags) == 0
1820
assert cm.read_blindly == True
@@ -32,6 +34,8 @@ def test_azure_table_mapping(self, azure_table_storage_connection_string, test_c
3234
table_name=test_container_name,
3335
sync_initially=False,
3436
read_blindly=True,
37+
read_blindly_error=False,
38+
read_blindly_default=None,
3539
)
3640
assert len(cm.etags) == 0
3741
assert cm.read_blindly == True
@@ -51,6 +55,8 @@ def test_gcp_storage_mapping(self, gcp_storage_project, test_container_name):
5155
bucket_name=test_container_name,
5256
sync_initially=False,
5357
read_blindly=True,
58+
read_blindly_error=False,
59+
read_blindly_default=None,
5460
)
5561
assert len(cm.etags) == 0
5662
assert cm.read_blindly == True
@@ -69,6 +75,8 @@ def test_aws_s3_mapping(self, test_container_name):
6975
bucket_name=test_container_name,
7076
sync_initially=False,
7177
read_blindly=True,
78+
read_blindly_error=False,
79+
read_blindly_default=None,
7280
)
7381
assert len(cm.etags) == 0
7482
assert cm.read_blindly == True

0 commit comments

Comments
 (0)