From 1a9c7aaa789b4b06390284a700260c6a1e456cfc Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Mon, 20 Dec 2021 23:22:09 -0800 Subject: [PATCH] Add type definitions in prep for #6086 https://github.com/pydata/xarray/pull/6086/ --- setup.cfg | 2 ++ xarray/core/dataset.py | 18 +++++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/setup.cfg b/setup.cfg index bd123262cf7..38aaf6f7467 100644 --- a/setup.cfg +++ b/setup.cfg @@ -198,6 +198,8 @@ ignore_missing_imports = True ignore_missing_imports = True [mypy-h5py.*] ignore_missing_imports = True +[mypy-importlib_metadata.*] +ignore_missing_imports = True [mypy-iris.*] ignore_missing_imports = True [mypy-matplotlib.*] diff --git a/xarray/core/dataset.py b/xarray/core/dataset.py index 83c7b154658..fcbbcc7586b 100644 --- a/xarray/core/dataset.py +++ b/xarray/core/dataset.py @@ -1068,14 +1068,14 @@ def persist(self, **kwargs) -> "Dataset": @classmethod def _construct_direct( cls, - variables, - coord_names, - dims=None, - attrs=None, - indexes=None, - encoding=None, - close=None, - ): + variables: Mapping[Hashable, Variable], + coord_names: Set[Hashable], + dims: Mapping[Hashable, int] = None, + attrs: Mapping = None, + indexes: Mapping[Hashable, Index] = None, + encoding: Mapping = None, + close: Callable[[], None] = None, + ) -> "Dataset": """Shortcut around __init__ for internal use when we want to skip costly validation """ @@ -2359,7 +2359,7 @@ def isel( indexers = drop_dims_from_indexers(indexers, self.dims, missing_dims) variables = {} - dims: Dict[Hashable, Tuple[int, ...]] = {} + dims: Dict[Hashable, int] = {} coord_names = self._coord_names.copy() indexes = self._indexes.copy() if self._indexes is not None else None