Skip to content

Commit

Permalink
raise Error if unsupported kwarg is passed
Browse files Browse the repository at this point in the history
  • Loading branch information
headtr1ck committed Jan 14, 2024
1 parent 041c357 commit cec1a88
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 37 deletions.
22 changes: 12 additions & 10 deletions xarray/backends/h5netcdf_.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,19 +481,21 @@ def open_dataset(
filename_or_obj = _normalize_path(filename_or_obj)
store = H5NetCDFStore.open(
filename_or_obj,
mode=kwargs.get("mode", self.mode),
format=kwargs.get("format", self.format),
group=kwargs.get("group", self.group),
lock=kwargs.get("lock", self.lock),
autoclose=kwargs.get("autoclose", self.autoclose),
invalid_netcdf=kwargs.get("invalid_netcdf", self.invalid_netcdf),
phony_dims=kwargs.get("phony_dims", self.phony_dims),
decode_vlen_strings=kwargs.get(
mode=kwargs.pop("mode", self.mode),
format=kwargs.pop("format", self.format),
group=kwargs.pop("group", self.group),
lock=kwargs.pop("lock", self.lock),
autoclose=kwargs.pop("autoclose", self.autoclose),
invalid_netcdf=kwargs.pop("invalid_netcdf", self.invalid_netcdf),
phony_dims=kwargs.pop("phony_dims", self.phony_dims),
decode_vlen_strings=kwargs.pop(
"decode_vlen_strings", self.decode_vlen_strings
),
driver=kwargs.get("driver", self.driver),
driver_kwds=kwargs.get("driver_kwds", self.driver_kwds),
driver=kwargs.pop("driver", self.driver),
driver_kwds=kwargs.pop("driver_kwds", self.driver_kwds),
)
if kwargs:
raise ValueError(f"Unsupported kwargs: {kwargs.values()}")

store_entrypoint = StoreBackendEntrypoint()
ds = store_entrypoint.open_dataset(
Expand Down
18 changes: 10 additions & 8 deletions xarray/backends/netCDF4_.py
Original file line number Diff line number Diff line change
Expand Up @@ -676,15 +676,17 @@ def open_dataset(
filename_or_obj = _normalize_path(filename_or_obj)
store = NetCDF4DataStore.open(
filename_or_obj,
mode=kwargs.get("mode", self.mode),
format=kwargs.get("format", self.format),
group=kwargs.get("group", self.group),
clobber=kwargs.get("clobber", self.clobber),
diskless=kwargs.get("diskless", self.diskless),
persist=kwargs.get("persist", self.persist),
lock=kwargs.get("lock", self.lock),
autoclose=kwargs.get("autoclose", self.autoclose),
mode=kwargs.pop("mode", self.mode),
format=kwargs.pop("format", self.format),
group=kwargs.pop("group", self.group),
clobber=kwargs.pop("clobber", self.clobber),
diskless=kwargs.pop("diskless", self.diskless),
persist=kwargs.pop("persist", self.persist),
lock=kwargs.pop("lock", self.lock),
autoclose=kwargs.pop("autoclose", self.autoclose),
)
if kwargs:
raise ValueError(f"Unsupported kwargs: {kwargs.values()}")

store_entrypoint = StoreBackendEntrypoint()
with close_on_error(store):
Expand Down
14 changes: 8 additions & 6 deletions xarray/backends/pydap_.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,15 @@ def open_dataset(
)
store = PydapDataStore.open(
url=filename_or_obj,
application=kwargs.get("application", self.application),
session=kwargs.get("session", self.session),
output_grid=kwargs.get("output_grid", self.output_grid),
timeout=kwargs.get("timeout", self.timeout),
verify=kwargs.get("verify", self.verify),
user_charset=kwargs.get("user_charset", self.user_charset),
application=kwargs.pop("application", self.application),
session=kwargs.pop("session", self.session),
output_grid=kwargs.pop("output_grid", self.output_grid),
timeout=kwargs.pop("timeout", self.timeout),
verify=kwargs.pop("verify", self.verify),
user_charset=kwargs.pop("user_charset", self.user_charset),
)
if kwargs:
raise ValueError(f"Unsupported kwargs: {kwargs.values()}")

store_entrypoint = StoreBackendEntrypoint()
with close_on_error(store):
Expand Down
12 changes: 7 additions & 5 deletions xarray/backends/scipy_.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,12 +356,14 @@ def open_dataset(
filename_or_obj = _normalize_path(filename_or_obj)
store = ScipyDataStore(
filename_or_obj,
mode=kwargs.get("mode", self.mode),
format=kwargs.get("format", self.format),
group=kwargs.get("group", self.group),
mmap=kwargs.get("mmap", self.mmap),
lock=kwargs.get("lock", self.lock),
mode=kwargs.pop("mode", self.mode),
format=kwargs.pop("format", self.format),
group=kwargs.pop("group", self.group),
mmap=kwargs.pop("mmap", self.mmap),
lock=kwargs.pop("lock", self.lock),
)
if kwargs:
raise ValueError(f"Unsupported kwargs: {kwargs.values()}")

store_entrypoint = StoreBackendEntrypoint()
with close_on_error(store):
Expand Down
18 changes: 10 additions & 8 deletions xarray/backends/zarr.py
Original file line number Diff line number Diff line change
Expand Up @@ -1043,16 +1043,18 @@ def open_dataset(
filename_or_obj = _normalize_path(filename_or_obj)
store = ZarrStore.open_group(
filename_or_obj,
group=kwargs.get("group", self.group),
mode=kwargs.get("mode", self.mode),
synchronizer=kwargs.get("synchronizer", self.synchronizer),
consolidated=kwargs.get("consolidated", self.consolidated),
group=kwargs.pop("group", self.group),
mode=kwargs.pop("mode", self.mode),
synchronizer=kwargs.pop("synchronizer", self.synchronizer),
consolidated=kwargs.pop("consolidated", self.consolidated),
consolidate_on_close=False,
chunk_store=kwargs.get("chunk_store", self.chunk_store),
storage_options=kwargs.get("storage_options", self.storage_options),
stacklevel=kwargs.get("stacklevel", self.stacklevel) + 1,
zarr_version=kwargs.get("zarr_version", self.zarr_version),
chunk_store=kwargs.pop("chunk_store", self.chunk_store),
storage_options=kwargs.pop("storage_options", self.storage_options),
stacklevel=kwargs.pop("stacklevel", self.stacklevel) + 1,
zarr_version=kwargs.pop("zarr_version", self.zarr_version),
)
if kwargs:
raise ValueError(f"Unsupported kwargs: {kwargs.values()}")

store_entrypoint = StoreBackendEntrypoint()
with close_on_error(store):
Expand Down

0 comments on commit cec1a88

Please sign in to comment.