Skip to content

Commit 93ef61c

Browse files
committed
pre-commit run --all
1 parent 2e3aa83 commit 93ef61c

37 files changed

+499
-272
lines changed

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ repos:
1313
- id: mixed-line-ending
1414
- repo: https://github.com/astral-sh/ruff-pre-commit
1515
# Ruff version.
16-
rev: 'v0.2.1'
16+
rev: 'v0.2.2'
1717
hooks:
1818
- id: ruff
1919
args: ["--fix", "--show-fixes"]

asv_bench/benchmarks/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ def _skip_slow():
6767
>>> from . import _skip_slow
6868
>>> def time_something_slow():
6969
... pass
70-
...
7170
>>> time_something.setup = _skip_slow
7271
"""
7372
if os.environ.get("ASV_SKIP_SLOW", "0") == "1":

doc/examples/apply_ufunc_vectorize_1d.ipynb

+2-1
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,8 @@
460460
"interped = interped.rename({\"new_lat\": \"lat\"})\n",
461461
"interped[\"lat\"] = newlat # need to add this manually\n",
462462
"xr.testing.assert_allclose(\n",
463-
" expected.transpose(*interped.dims), interped # order of dims is different\n",
463+
" expected.transpose(*interped.dims),\n",
464+
" interped, # order of dims is different\n",
464465
")\n",
465466
"interped"
466467
]

xarray/backends/api.py

+18-9
Original file line numberDiff line numberDiff line change
@@ -1132,7 +1132,8 @@ def to_netcdf(
11321132
*,
11331133
multifile: Literal[True],
11341134
invalid_netcdf: bool = False,
1135-
) -> tuple[ArrayWriter, AbstractDataStore]: ...
1135+
) -> tuple[ArrayWriter, AbstractDataStore]:
1136+
...
11361137

11371138

11381139
# path=None writes to bytes
@@ -1149,7 +1150,8 @@ def to_netcdf(
11491150
compute: bool = True,
11501151
multifile: Literal[False] = False,
11511152
invalid_netcdf: bool = False,
1152-
) -> bytes: ...
1153+
) -> bytes:
1154+
...
11531155

11541156

11551157
# compute=False returns dask.Delayed
@@ -1167,7 +1169,8 @@ def to_netcdf(
11671169
compute: Literal[False],
11681170
multifile: Literal[False] = False,
11691171
invalid_netcdf: bool = False,
1170-
) -> Delayed: ...
1172+
) -> Delayed:
1173+
...
11711174

11721175

11731176
# default return None
@@ -1184,7 +1187,8 @@ def to_netcdf(
11841187
compute: Literal[True] = True,
11851188
multifile: Literal[False] = False,
11861189
invalid_netcdf: bool = False,
1187-
) -> None: ...
1190+
) -> None:
1191+
...
11881192

11891193

11901194
# if compute cannot be evaluated at type check time
@@ -1202,7 +1206,8 @@ def to_netcdf(
12021206
compute: bool = False,
12031207
multifile: Literal[False] = False,
12041208
invalid_netcdf: bool = False,
1205-
) -> Delayed | None: ...
1209+
) -> Delayed | None:
1210+
...
12061211

12071212

12081213
# if multifile cannot be evaluated at type check time
@@ -1220,7 +1225,8 @@ def to_netcdf(
12201225
compute: bool = False,
12211226
multifile: bool = False,
12221227
invalid_netcdf: bool = False,
1223-
) -> tuple[ArrayWriter, AbstractDataStore] | Delayed | None: ...
1228+
) -> tuple[ArrayWriter, AbstractDataStore] | Delayed | None:
1229+
...
12241230

12251231

12261232
# Any
@@ -1237,7 +1243,8 @@ def to_netcdf(
12371243
compute: bool = False,
12381244
multifile: bool = False,
12391245
invalid_netcdf: bool = False,
1240-
) -> tuple[ArrayWriter, AbstractDataStore] | bytes | Delayed | None: ...
1246+
) -> tuple[ArrayWriter, AbstractDataStore] | bytes | Delayed | None:
1247+
...
12411248

12421249

12431250
def to_netcdf(
@@ -1671,7 +1678,8 @@ def to_zarr(
16711678
zarr_version: int | None = None,
16721679
write_empty_chunks: bool | None = None,
16731680
chunkmanager_store_kwargs: dict[str, Any] | None = None,
1674-
) -> backends.ZarrStore: ...
1681+
) -> backends.ZarrStore:
1682+
...
16751683

16761684

16771685
# compute=False returns dask.Delayed
@@ -1694,7 +1702,8 @@ def to_zarr(
16941702
zarr_version: int | None = None,
16951703
write_empty_chunks: bool | None = None,
16961704
chunkmanager_store_kwargs: dict[str, Any] | None = None,
1697-
) -> Delayed: ...
1705+
) -> Delayed:
1706+
...
16981707

16991708

17001709
def to_zarr(

xarray/backends/common.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -235,13 +235,10 @@ def load(self):
235235
For example::
236236
237237
class SuffixAppendingDataStore(AbstractDataStore):
238-
239238
def load(self):
240239
variables, attributes = AbstractDataStore.load(self)
241-
variables = {'%s_suffix' % k: v
242-
for k, v in variables.items()}
243-
attributes = {'%s_suffix' % k: v
244-
for k, v in attributes.items()}
240+
variables = {"%s_suffix" % k: v for k, v in variables.items()}
241+
attributes = {"%s_suffix" % k: v for k, v in attributes.items()}
245242
return variables, attributes
246243
247244
This function will be called anytime variables or attributes

xarray/backends/locks.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ class SerializableLock:
4040
The creation of locks is itself not threadsafe.
4141
"""
4242

43-
_locks: ClassVar[WeakValueDictionary[Hashable, threading.Lock]] = (
44-
WeakValueDictionary()
45-
)
43+
_locks: ClassVar[
44+
WeakValueDictionary[Hashable, threading.Lock]
45+
] = WeakValueDictionary()
4646
token: Hashable
4747
lock: threading.Lock
4848

xarray/backends/plugins.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def backends_dict_from_pkg(
8282

8383

8484
def set_missing_parameters(
85-
backend_entrypoints: dict[str, type[BackendEntrypoint]]
85+
backend_entrypoints: dict[str, type[BackendEntrypoint]],
8686
) -> None:
8787
for _, backend in backend_entrypoints.items():
8888
if backend.open_dataset_parameters is None:
@@ -91,7 +91,7 @@ def set_missing_parameters(
9191

9292

9393
def sort_backends(
94-
backend_entrypoints: dict[str, type[BackendEntrypoint]]
94+
backend_entrypoints: dict[str, type[BackendEntrypoint]],
9595
) -> dict[str, type[BackendEntrypoint]]:
9696
ordered_backends_entrypoints = {}
9797
for be_name in STANDARD_BACKENDS_ORDER:

xarray/core/_typed_ops.py

+72-36
Original file line numberDiff line numberDiff line change
@@ -455,163 +455,199 @@ def _binary_op(
455455
raise NotImplementedError
456456

457457
@overload
458-
def __add__(self, other: T_DataArray) -> T_DataArray: ...
458+
def __add__(self, other: T_DataArray) -> T_DataArray:
459+
...
459460

460461
@overload
461-
def __add__(self, other: VarCompatible) -> Self: ...
462+
def __add__(self, other: VarCompatible) -> Self:
463+
...
462464

463465
def __add__(self, other: VarCompatible) -> Self | T_DataArray:
464466
return self._binary_op(other, operator.add)
465467

466468
@overload
467-
def __sub__(self, other: T_DataArray) -> T_DataArray: ...
469+
def __sub__(self, other: T_DataArray) -> T_DataArray:
470+
...
468471

469472
@overload
470-
def __sub__(self, other: VarCompatible) -> Self: ...
473+
def __sub__(self, other: VarCompatible) -> Self:
474+
...
471475

472476
def __sub__(self, other: VarCompatible) -> Self | T_DataArray:
473477
return self._binary_op(other, operator.sub)
474478

475479
@overload
476-
def __mul__(self, other: T_DataArray) -> T_DataArray: ...
480+
def __mul__(self, other: T_DataArray) -> T_DataArray:
481+
...
477482

478483
@overload
479-
def __mul__(self, other: VarCompatible) -> Self: ...
484+
def __mul__(self, other: VarCompatible) -> Self:
485+
...
480486

481487
def __mul__(self, other: VarCompatible) -> Self | T_DataArray:
482488
return self._binary_op(other, operator.mul)
483489

484490
@overload
485-
def __pow__(self, other: T_DataArray) -> T_DataArray: ...
491+
def __pow__(self, other: T_DataArray) -> T_DataArray:
492+
...
486493

487494
@overload
488-
def __pow__(self, other: VarCompatible) -> Self: ...
495+
def __pow__(self, other: VarCompatible) -> Self:
496+
...
489497

490498
def __pow__(self, other: VarCompatible) -> Self | T_DataArray:
491499
return self._binary_op(other, operator.pow)
492500

493501
@overload
494-
def __truediv__(self, other: T_DataArray) -> T_DataArray: ...
502+
def __truediv__(self, other: T_DataArray) -> T_DataArray:
503+
...
495504

496505
@overload
497-
def __truediv__(self, other: VarCompatible) -> Self: ...
506+
def __truediv__(self, other: VarCompatible) -> Self:
507+
...
498508

499509
def __truediv__(self, other: VarCompatible) -> Self | T_DataArray:
500510
return self._binary_op(other, operator.truediv)
501511

502512
@overload
503-
def __floordiv__(self, other: T_DataArray) -> T_DataArray: ...
513+
def __floordiv__(self, other: T_DataArray) -> T_DataArray:
514+
...
504515

505516
@overload
506-
def __floordiv__(self, other: VarCompatible) -> Self: ...
517+
def __floordiv__(self, other: VarCompatible) -> Self:
518+
...
507519

508520
def __floordiv__(self, other: VarCompatible) -> Self | T_DataArray:
509521
return self._binary_op(other, operator.floordiv)
510522

511523
@overload
512-
def __mod__(self, other: T_DataArray) -> T_DataArray: ...
524+
def __mod__(self, other: T_DataArray) -> T_DataArray:
525+
...
513526

514527
@overload
515-
def __mod__(self, other: VarCompatible) -> Self: ...
528+
def __mod__(self, other: VarCompatible) -> Self:
529+
...
516530

517531
def __mod__(self, other: VarCompatible) -> Self | T_DataArray:
518532
return self._binary_op(other, operator.mod)
519533

520534
@overload
521-
def __and__(self, other: T_DataArray) -> T_DataArray: ...
535+
def __and__(self, other: T_DataArray) -> T_DataArray:
536+
...
522537

523538
@overload
524-
def __and__(self, other: VarCompatible) -> Self: ...
539+
def __and__(self, other: VarCompatible) -> Self:
540+
...
525541

526542
def __and__(self, other: VarCompatible) -> Self | T_DataArray:
527543
return self._binary_op(other, operator.and_)
528544

529545
@overload
530-
def __xor__(self, other: T_DataArray) -> T_DataArray: ...
546+
def __xor__(self, other: T_DataArray) -> T_DataArray:
547+
...
531548

532549
@overload
533-
def __xor__(self, other: VarCompatible) -> Self: ...
550+
def __xor__(self, other: VarCompatible) -> Self:
551+
...
534552

535553
def __xor__(self, other: VarCompatible) -> Self | T_DataArray:
536554
return self._binary_op(other, operator.xor)
537555

538556
@overload
539-
def __or__(self, other: T_DataArray) -> T_DataArray: ...
557+
def __or__(self, other: T_DataArray) -> T_DataArray:
558+
...
540559

541560
@overload
542-
def __or__(self, other: VarCompatible) -> Self: ...
561+
def __or__(self, other: VarCompatible) -> Self:
562+
...
543563

544564
def __or__(self, other: VarCompatible) -> Self | T_DataArray:
545565
return self._binary_op(other, operator.or_)
546566

547567
@overload
548-
def __lshift__(self, other: T_DataArray) -> T_DataArray: ...
568+
def __lshift__(self, other: T_DataArray) -> T_DataArray:
569+
...
549570

550571
@overload
551-
def __lshift__(self, other: VarCompatible) -> Self: ...
572+
def __lshift__(self, other: VarCompatible) -> Self:
573+
...
552574

553575
def __lshift__(self, other: VarCompatible) -> Self | T_DataArray:
554576
return self._binary_op(other, operator.lshift)
555577

556578
@overload
557-
def __rshift__(self, other: T_DataArray) -> T_DataArray: ...
579+
def __rshift__(self, other: T_DataArray) -> T_DataArray:
580+
...
558581

559582
@overload
560-
def __rshift__(self, other: VarCompatible) -> Self: ...
583+
def __rshift__(self, other: VarCompatible) -> Self:
584+
...
561585

562586
def __rshift__(self, other: VarCompatible) -> Self | T_DataArray:
563587
return self._binary_op(other, operator.rshift)
564588

565589
@overload
566-
def __lt__(self, other: T_DataArray) -> T_DataArray: ...
590+
def __lt__(self, other: T_DataArray) -> T_DataArray:
591+
...
567592

568593
@overload
569-
def __lt__(self, other: VarCompatible) -> Self: ...
594+
def __lt__(self, other: VarCompatible) -> Self:
595+
...
570596

571597
def __lt__(self, other: VarCompatible) -> Self | T_DataArray:
572598
return self._binary_op(other, operator.lt)
573599

574600
@overload
575-
def __le__(self, other: T_DataArray) -> T_DataArray: ...
601+
def __le__(self, other: T_DataArray) -> T_DataArray:
602+
...
576603

577604
@overload
578-
def __le__(self, other: VarCompatible) -> Self: ...
605+
def __le__(self, other: VarCompatible) -> Self:
606+
...
579607

580608
def __le__(self, other: VarCompatible) -> Self | T_DataArray:
581609
return self._binary_op(other, operator.le)
582610

583611
@overload
584-
def __gt__(self, other: T_DataArray) -> T_DataArray: ...
612+
def __gt__(self, other: T_DataArray) -> T_DataArray:
613+
...
585614

586615
@overload
587-
def __gt__(self, other: VarCompatible) -> Self: ...
616+
def __gt__(self, other: VarCompatible) -> Self:
617+
...
588618

589619
def __gt__(self, other: VarCompatible) -> Self | T_DataArray:
590620
return self._binary_op(other, operator.gt)
591621

592622
@overload
593-
def __ge__(self, other: T_DataArray) -> T_DataArray: ...
623+
def __ge__(self, other: T_DataArray) -> T_DataArray:
624+
...
594625

595626
@overload
596-
def __ge__(self, other: VarCompatible) -> Self: ...
627+
def __ge__(self, other: VarCompatible) -> Self:
628+
...
597629

598630
def __ge__(self, other: VarCompatible) -> Self | T_DataArray:
599631
return self._binary_op(other, operator.ge)
600632

601633
@overload # type:ignore[override]
602-
def __eq__(self, other: T_DataArray) -> T_DataArray: ...
634+
def __eq__(self, other: T_DataArray) -> T_DataArray:
635+
...
603636

604637
@overload
605-
def __eq__(self, other: VarCompatible) -> Self: ...
638+
def __eq__(self, other: VarCompatible) -> Self:
639+
...
606640

607641
def __eq__(self, other: VarCompatible) -> Self | T_DataArray:
608642
return self._binary_op(other, nputils.array_eq)
609643

610644
@overload # type:ignore[override]
611-
def __ne__(self, other: T_DataArray) -> T_DataArray: ...
645+
def __ne__(self, other: T_DataArray) -> T_DataArray:
646+
...
612647

613648
@overload
614-
def __ne__(self, other: VarCompatible) -> Self: ...
649+
def __ne__(self, other: VarCompatible) -> Self:
650+
...
615651

616652
def __ne__(self, other: VarCompatible) -> Self | T_DataArray:
617653
return self._binary_op(other, nputils.array_ne)

0 commit comments

Comments
 (0)