Skip to content

Commit

Permalink
Fix UP007
Browse files Browse the repository at this point in the history
  • Loading branch information
dcherian committed Aug 13, 2024
1 parent 40c754a commit 3e4d587
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 25 deletions.
24 changes: 12 additions & 12 deletions xarray/core/merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from collections import defaultdict
from collections.abc import Hashable, Iterable, Mapping, Sequence, Set
from typing import TYPE_CHECKING, Any, NamedTuple, Union
from typing import TYPE_CHECKING, Any, NamedTuple

import pandas as pd

Expand All @@ -24,18 +24,18 @@
from xarray.core.dataset import Dataset
from xarray.core.types import CombineAttrsOptions, CompatOptions, JoinOptions

DimsLike = Union[Hashable, Sequence[Hashable]]
DimsLike = Hashable | Sequence[Hashable]
ArrayLike = Any
VariableLike = Union[
ArrayLike,
tuple[DimsLike, ArrayLike],
tuple[DimsLike, ArrayLike, Mapping],
tuple[DimsLike, ArrayLike, Mapping, Mapping],
]
XarrayValue = Union[DataArray, Variable, VariableLike]
DatasetLike = Union[Dataset, Coordinates, Mapping[Any, XarrayValue]]
CoercibleValue = Union[XarrayValue, pd.Series, pd.DataFrame]
CoercibleMapping = Union[Dataset, Mapping[Any, CoercibleValue]]
VariableLike = (
ArrayLike
| tuple[DimsLike, ArrayLike]
| tuple[DimsLike, ArrayLike, Mapping]
| tuple[DimsLike, ArrayLike, Mapping, Mapping]
)
XarrayValue = DataArray | Variable | VariableLike
DatasetLike = Dataset | Coordinates | Mapping[Any, XarrayValue]
CoercibleValue = XarrayValue | pd.Series | pd.DataFrame
CoercibleMapping = Dataset | Mapping[Any, CoercibleValue]


PANDAS_TYPES = (pd.Series, pd.DataFrame)
Expand Down
31 changes: 18 additions & 13 deletions xarray/core/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@
ZarrArray = np.ndarray

# Anything that can be coerced to a shape tuple
_ShapeLike = Union[SupportsIndex, Sequence[SupportsIndex]]
_ShapeLike = SupportsIndex | Sequence[SupportsIndex]
_DTypeLikeNested = Any # TODO: wait for support for recursive types

# Xarray requires a Mapping[Hashable, dtype] in many places which
# conflicts with numpys own DTypeLike (with dtypes for fields).
# https://numpy.org/devdocs/reference/typing.html#numpy.typing.DTypeLike
# This is a copy of this DTypeLike that allows only non-Mapping dtypes.
DTypeLikeSave = Union[
DTypeLikeSave = Union[ # noqa
np.dtype[Any],
# default data type (float64)
None,
Expand Down Expand Up @@ -209,17 +209,17 @@ def copy(
"identical", "equals", "broadcast_equals", "no_conflicts", "override", "minimal"
]
ConcatOptions = Literal["all", "minimal", "different"]
CombineAttrsOptions = Union[
Literal["drop", "identical", "no_conflicts", "drop_conflicts", "override"],
Callable[..., Any],
]
CombineAttrsOptions = (
Literal["drop", "identical", "no_conflicts", "drop_conflicts", "override"]
| Callable[..., Any]
)
JoinOptions = Literal["outer", "inner", "left", "right", "exact", "override"]

Interp1dOptions = Literal[
"linear", "nearest", "zero", "slinear", "quadratic", "cubic", "polynomial"
]
InterpolantOptions = Literal["barycentric", "krogh", "pchip", "spline", "akima"]
InterpOptions = Union[Interp1dOptions, InterpolantOptions]
InterpOptions = Interp1dOptions | InterpolantOptions

DatetimeUnitOptions = Literal[
"Y", "M", "W", "D", "h", "m", "s", "ms", "us", "μs", "ns", "ps", "fs", "as", None
Expand Down Expand Up @@ -263,12 +263,12 @@ def copy(

ScaleOptions = Literal["linear", "symlog", "log", "logit", None]
HueStyleOptions = Literal["continuous", "discrete", None]
AspectOptions = Union[Literal["auto", "equal"], float, None]
AspectOptions = Literal["auto", "equal"] | float | None
ExtendOptions = Literal["neither", "both", "min", "max", None]

# TODO: Wait until mypy supports recursive objects in combination with typevars
_T = TypeVar("_T")
NestedSequence = Union[
NestedSequence = Union[ # noqa
_T,
Sequence[_T],
Sequence[Sequence[_T]],
Expand Down Expand Up @@ -298,8 +298,13 @@ def copy(
ZarrWriteModes = Literal["w", "w-", "a", "a-", "r+", "r"]

GroupKey = Any
GroupIndex = Union[int, slice, list[int]]
GroupIndex = int | slice | list[int]
GroupIndices = tuple[GroupIndex, ...]
Bins = Union[
int, Sequence[int], Sequence[float], Sequence[pd.Timestamp], np.ndarray, pd.Index
]
Bins = (
int
| Sequence[int]
| Sequence[float]
| Sequence[pd.Timestamp]
| np.ndarray
| pd.Index
)

0 comments on commit 3e4d587

Please sign in to comment.