diff --git a/xarray/backends/pydap_.py b/xarray/backends/pydap_.py index d2ea536f587..cbda4891508 100644 --- a/xarray/backends/pydap_.py +++ b/xarray/backends/pydap_.py @@ -100,38 +100,26 @@ def open( user_charset=None, ): - if output_grid is None: - output_grid = True - - if verify is None: - verify = True - if timeout is None: from pydap.lib import DEFAULT_TIMEOUT timeout = DEFAULT_TIMEOUT - if user_charset is None: - user_charset = "ascii" - + kwargs = { + "url": url, + "application": application, + "session": session, + "output_grid": output_grid or True, + "timeout": timeout, + } if Version(pydap_version) >= Version("3.3.0"): - ds = pydap.client.open_url( - url=url, - application=application, - session=session, - output_grid=output_grid, - timeout=timeout, - verify=verify, - user_charset=user_charset, - ) - else: - ds = pydap.client.open_url( - url=url, - application=application, - session=session, - output_grid=output_grid, - timeout=timeout, + kwargs.update( + { + "verify": verify if verify is not None else True, + "user_charset": user_charset or "ascii", + } ) + ds = pydap.client.open_url(**kwargs) return cls(ds) def open_store_variable(self, var):