Skip to content

Commit b88d841

Browse files
[pre-commit.ci] pre-commit autoupdate (#7997)
* [pre-commit.ci] pre-commit autoupdate updates: - [github.com/astral-sh/ruff-pre-commit: v0.0.277 → v0.0.278](astral-sh/ruff-pre-commit@v0.0.277...v0.0.278) - [github.com/psf/black: 23.3.0 → 23.7.0](psf/black@23.3.0...23.7.0) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 7234603 commit b88d841

File tree

8 files changed

+14
-38
lines changed

8 files changed

+14
-38
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,21 @@ repos:
1616
files: ^xarray/
1717
- repo: https://github.com/astral-sh/ruff-pre-commit
1818
# Ruff version.
19-
rev: 'v0.0.277'
19+
rev: 'v0.0.278'
2020
hooks:
2121
- id: ruff
2222
args: ["--fix"]
2323
# https://github.com/python/black#version-control-integration
2424
- repo: https://github.com/psf/black
25-
rev: 23.3.0
25+
rev: 23.7.0
2626
hooks:
2727
- id: black-jupyter
2828
- repo: https://github.com/keewis/blackdoc
2929
rev: v0.3.8
3030
hooks:
3131
- id: blackdoc
3232
exclude: "generate_aggregations.py"
33-
additional_dependencies: ["black==23.3.0"]
33+
additional_dependencies: ["black==23.7.0"]
3434
- id: blackdoc-autoupdate-black
3535
- repo: https://github.com/pre-commit/mirrors-mypy
3636
rev: v1.4.1

xarray/core/common.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -307,9 +307,7 @@ def __setattr__(self, name: str, value: Any) -> None:
307307
except AttributeError as e:
308308
# Don't accidentally shadow custom AttributeErrors, e.g.
309309
# DataArray.dims.setter
310-
if str(e) != "{!r} object has no attribute {!r}".format(
311-
type(self).__name__, name
312-
):
310+
if str(e) != f"{type(self).__name__!r} object has no attribute {name!r}":
313311
raise
314312
raise AttributeError(
315313
f"cannot set attribute {name!r} on a {type(self).__name__!r} object. Use __setitem__ style"
@@ -1293,9 +1291,7 @@ def isin(self: T_DataWithCoords, test_elements: Any) -> T_DataWithCoords:
12931291

12941292
if isinstance(test_elements, Dataset):
12951293
raise TypeError(
1296-
"isin() argument must be convertible to an array: {}".format(
1297-
test_elements
1298-
)
1294+
f"isin() argument must be convertible to an array: {test_elements}"
12991295
)
13001296
elif isinstance(test_elements, (Variable, DataArray)):
13011297
# need to explicitly pull out data to support dask arrays as the

xarray/core/dataarray.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4676,11 +4676,7 @@ def _title_for_slice(self, truncate: int = 50) -> str:
46764676
for dim, coord in self.coords.items():
46774677
if coord.size == 1:
46784678
one_dims.append(
4679-
"{dim} = {v}{unit}".format(
4680-
dim=dim,
4681-
v=format_item(coord.values),
4682-
unit=_get_units_from_attrs(coord),
4683-
)
4679+
f"{dim} = {format_item(coord.values)}{_get_units_from_attrs(coord)}"
46844680
)
46854681

46864682
title = ", ".join(one_dims)

xarray/core/formatting.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -697,9 +697,7 @@ def dataset_repr(ds):
697697

698698
def diff_dim_summary(a, b):
699699
if a.dims != b.dims:
700-
return "Differing dimensions:\n ({}) != ({})".format(
701-
dim_summary(a), dim_summary(b)
702-
)
700+
return f"Differing dimensions:\n ({dim_summary(a)}) != ({dim_summary(b)})"
703701
else:
704702
return ""
705703

@@ -826,9 +824,7 @@ def _compat_to_str(compat):
826824
def diff_array_repr(a, b, compat):
827825
# used for DataArray, Variable and IndexVariable
828826
summary = [
829-
"Left and right {} objects are not {}".format(
830-
type(a).__name__, _compat_to_str(compat)
831-
)
827+
f"Left and right {type(a).__name__} objects are not {_compat_to_str(compat)}"
832828
]
833829

834830
summary.append(diff_dim_summary(a, b))
@@ -859,9 +855,7 @@ def diff_array_repr(a, b, compat):
859855

860856
def diff_dataset_repr(a, b, compat):
861857
summary = [
862-
"Left and right {} objects are not {}".format(
863-
type(a).__name__, _compat_to_str(compat)
864-
)
858+
f"Left and right {type(a).__name__} objects are not {_compat_to_str(compat)}"
865859
]
866860

867861
col_width = _calculate_col_width(set(list(a.variables) + list(b.variables)))

xarray/core/missing.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,7 @@ def __call__(self, x):
6666
return self.f(x, **self.call_kwargs)
6767

6868
def __repr__(self):
69-
return "{type}: method={method}".format(
70-
type=self.__class__.__name__, method=self.method
71-
)
69+
return f"{self.__class__.__name__}: method={self.method}"
7270

7371

7472
class NumpyInterpolator(BaseInterpolator):

xarray/core/parallel.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -406,9 +406,7 @@ def _wrapper(
406406
new_layers: collections.defaultdict[str, dict[Any, Any]] = collections.defaultdict(
407407
dict
408408
)
409-
gname = "{}-{}".format(
410-
dask.utils.funcname(func), dask.base.tokenize(npargs[0], args, kwargs)
411-
)
409+
gname = f"{dask.utils.funcname(func)}-{dask.base.tokenize(npargs[0], args, kwargs)}"
412410

413411
# map dims to list of chunk indexes
414412
ichunk = {dim: range(len(chunks_v)) for dim, chunks_v in input_chunks.items()}

xarray/core/variable.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,9 +1083,7 @@ def _copy(
10831083
ndata = as_compatible_data(data)
10841084
if self.shape != ndata.shape:
10851085
raise ValueError(
1086-
"Data shape {} must match shape of object {}".format(
1087-
ndata.shape, self.shape
1088-
)
1086+
f"Data shape {ndata.shape} must match shape of object {self.shape}"
10891087
)
10901088

10911089
attrs = copy.deepcopy(self._attrs, memo) if deep else copy.copy(self._attrs)
@@ -3044,9 +3042,7 @@ def copy(self, deep: bool = True, data: ArrayLike | None = None):
30443042
ndata = as_compatible_data(data)
30453043
if self.shape != ndata.shape:
30463044
raise ValueError(
3047-
"Data shape {} must match shape of object {}".format(
3048-
ndata.shape, self.shape
3049-
)
3045+
f"Data shape {ndata.shape} must match shape of object {self.shape}"
30503046
)
30513047

30523048
attrs = copy.deepcopy(self._attrs) if deep else copy.copy(self._attrs)

xarray/testing.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,5 @@ def _assert_internal_invariants(
403403
)
404404
else:
405405
raise TypeError(
406-
"{} is not a supported type for xarray invariant checks".format(
407-
type(xarray_obj)
408-
)
406+
f"{type(xarray_obj)} is not a supported type for xarray invariant checks"
409407
)

0 commit comments

Comments
 (0)