Skip to content

Commit

Permalink
More typing fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
dcherian committed Jun 13, 2024
1 parent 162e34a commit 8a980ef
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
7 changes: 4 additions & 3 deletions xarray/core/dataarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@
ReindexMethodOptions,
Self,
SideOptions,
T_Chunks,
T_ChunkDimFreq,
T_ChunksFreq,
T_Xarray,
)
from xarray.core.weighted import DataArrayWeighted
Expand Down Expand Up @@ -1336,15 +1337,15 @@ def chunksizes(self) -> Mapping[Any, tuple[int, ...]]:
@_deprecate_positional_args("v2023.10.0")
def chunk(
self,
chunks: T_Chunks = {}, # {} even though it's technically unsafe, is being used intentionally here (#4667)
chunks: T_ChunksFreq = {}, # {} even though it's technically unsafe, is being used intentionally here (#4667)
*,
name_prefix: str = "xarray-",
token: str | None = None,
lock: bool = False,
inline_array: bool = False,
chunked_array_type: str | ChunkManagerEntrypoint | None = None,
from_array_kwargs=None,
**chunks_kwargs: Any,
**chunks_kwargs: T_ChunkDimFreq,
) -> Self:
"""Coerce this array's data into a dask arrays with the given chunks.
Expand Down
7 changes: 4 additions & 3 deletions xarray/core/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
QuantileMethods,
Self,
T_ChunkDim,
T_Chunks,
T_ChunksFreq,
T_DataArray,
T_DataArrayOrSet,
T_Dataset,
Expand Down Expand Up @@ -159,6 +159,7 @@
QueryParserOptions,
ReindexMethodOptions,
SideOptions,
T_ChunkDimFreq,
T_Xarray,
)
from xarray.core.weighted import DatasetWeighted
Expand Down Expand Up @@ -2642,14 +2643,14 @@ def chunksizes(self) -> Mapping[Hashable, tuple[int, ...]]:

def chunk(
self,
chunks: T_Chunks = {}, # {} even though it's technically unsafe, is being used intentionally here (#4667)
chunks: T_ChunksFreq = {}, # {} even though it's technically unsafe, is being used intentionally here (#4667)
name_prefix: str = "xarray-",
token: str | None = None,
lock: bool = False,
inline_array: bool = False,
chunked_array_type: str | ChunkManagerEntrypoint | None = None,
from_array_kwargs=None,
**chunks_kwargs: T_ChunkDim,
**chunks_kwargs: T_ChunkDimFreq,
) -> Self:
"""Coerce all arrays in this dataset into dask arrays with the given
chunks.
Expand Down
3 changes: 2 additions & 1 deletion xarray/core/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,10 @@ def copy(
Dims = Union[str, Collection[Hashable], "ellipsis", None]

# FYI in some cases we don't allow `None`, which this doesn't take account of.
T_FreqStr: TypeAlias = str
T_FreqStr: TypeAlias = str # TODO: explicit list of supported pandas frequency strings
T_ChunkDim: TypeAlias = Union[int, Literal["auto"], None, tuple[int, ...]]
T_ChunkDimFreq: TypeAlias = Union[T_FreqStr, T_ChunkDim]
T_ChunksFreq: TypeAlias = Union[T_ChunkDimFreq, Mapping[Any, T_ChunkDimFreq]]
# We allow the tuple form of this (though arguably we could transition to named dims only)
T_Chunks: TypeAlias = Union[T_ChunkDim, Mapping[Any, T_ChunkDim]]
T_NormalizedChunks = tuple[tuple[int, ...], ...]
Expand Down

0 comments on commit 8a980ef

Please sign in to comment.