diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 973574d276e..25e9ea21aab 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,7 +16,7 @@ repos: files: ^xarray/ - repo: https://github.com/charliermarsh/ruff-pre-commit # Ruff version. - rev: 'v0.0.254' + rev: 'v0.0.257' hooks: - id: ruff args: ["--fix"] diff --git a/xarray/core/computation.py b/xarray/core/computation.py index 9b282d32a45..9af7fcd89a4 100644 --- a/xarray/core/computation.py +++ b/xarray/core/computation.py @@ -8,17 +8,8 @@ import operator import warnings from collections import Counter -from collections.abc import Hashable, Iterable, Mapping, Sequence -from typing import ( - TYPE_CHECKING, - AbstractSet, - Any, - Callable, - Literal, - TypeVar, - Union, - overload, -) +from collections.abc import Hashable, Iterable, Mapping, Sequence, Set +from typing import TYPE_CHECKING, Any, Callable, Literal, TypeVar, Union, overload import numpy as np @@ -211,7 +202,7 @@ def _get_coords_list(args: Iterable[Any]) -> list[Coordinates]: def build_output_coords_and_indexes( args: Iterable[Any], signature: _UFuncSignature, - exclude_dims: AbstractSet = frozenset(), + exclude_dims: Set = frozenset(), combine_attrs: CombineAttrsOptions = "override", ) -> tuple[list[dict[Any, Variable]], list[dict[Any, Index]]]: """Build output coordinates and indexes for an operation. @@ -561,7 +552,7 @@ def apply_groupby_func(func, *args): def unified_dim_sizes( - variables: Iterable[Variable], exclude_dims: AbstractSet = frozenset() + variables: Iterable[Variable], exclude_dims: Set = frozenset() ) -> dict[Hashable, int]: dim_sizes: dict[Hashable, int] = {} @@ -846,7 +837,7 @@ def apply_ufunc( *args: Any, input_core_dims: Sequence[Sequence] | None = None, output_core_dims: Sequence[Sequence] | None = ((),), - exclude_dims: AbstractSet = frozenset(), + exclude_dims: Set = frozenset(), vectorize: bool = False, join: JoinOptions = "exact", dataset_join: str = "exact", diff --git a/xarray/core/merge.py b/xarray/core/merge.py index 6cb758851b4..bf7288ad7ed 100644 --- a/xarray/core/merge.py +++ b/xarray/core/merge.py @@ -1,8 +1,8 @@ from __future__ import annotations from collections import defaultdict -from collections.abc import Hashable, Iterable, Mapping, Sequence -from typing import TYPE_CHECKING, AbstractSet, Any, NamedTuple, Optional, Union +from collections.abc import Hashable, Iterable, Mapping, Sequence, Set +from typing import TYPE_CHECKING, Any, NamedTuple, Optional, Union import pandas as pd @@ -381,7 +381,7 @@ def collect_from_coordinates( def merge_coordinates_without_align( objects: list[Coordinates], prioritized: Mapping[Any, MergeElement] | None = None, - exclude_dims: AbstractSet = frozenset(), + exclude_dims: Set = frozenset(), combine_attrs: CombineAttrsOptions = "override", ) -> tuple[dict[Hashable, Variable], dict[Hashable, Index]]: """Merge variables/indexes from coordinates without automatic alignments. diff --git a/xarray/core/parallel.py b/xarray/core/parallel.py index af3bc9340c6..2f8612c5a9b 100644 --- a/xarray/core/parallel.py +++ b/xarray/core/parallel.py @@ -4,7 +4,7 @@ import itertools import operator from collections.abc import Hashable, Iterable, Mapping, Sequence -from typing import TYPE_CHECKING, Any, Callable, DefaultDict +from typing import TYPE_CHECKING, Any, Callable import numpy as np @@ -403,7 +403,9 @@ def _wrapper( # func applied to the values. graph: dict[Any, Any] = {} - new_layers: DefaultDict[str, dict[Any, Any]] = collections.defaultdict(dict) + new_layers: collections.defaultdict[str, dict[Any, Any]] = collections.defaultdict( + dict + ) gname = "{}-{}".format( dask.utils.funcname(func), dask.base.tokenize(npargs[0], args, kwargs) )