Skip to content

Commit 2d51956

Browse files
Apply ruff rule RUF023
RUF023 `__slots__` is not sorted
1 parent 97f1f8f commit 2d51956

15 files changed

+56
-56
lines changed

xarray/backends/common.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ def __exit__(self, exception_type, exception_value, traceback):
276276

277277

278278
class ArrayWriter:
279-
__slots__ = ("sources", "targets", "regions", "lock")
279+
__slots__ = ("lock", "regions", "sources", "targets")
280280

281281
def __init__(self, lock=None):
282282
self.sources = []

xarray/backends/h5netcdf_.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,14 @@ class H5NetCDFStore(WritableCFDataStore):
100100
"""Store for reading and writing data via h5netcdf"""
101101

102102
__slots__ = (
103-
"autoclose",
104-
"format",
105-
"is_remote",
106-
"lock",
107103
"_filename",
108104
"_group",
109105
"_manager",
110106
"_mode",
107+
"autoclose",
108+
"format",
109+
"is_remote",
110+
"lock",
111111
)
112112

113113
def __init__(self, manager, group=None, mode=None, lock=HDF5_LOCK, autoclose=False):

xarray/backends/netCDF4_.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -361,14 +361,14 @@ class NetCDF4DataStore(WritableCFDataStore):
361361
"""
362362

363363
__slots__ = (
364-
"autoclose",
365-
"format",
366-
"is_remote",
367-
"lock",
368364
"_filename",
369365
"_group",
370366
"_manager",
371367
"_mode",
368+
"autoclose",
369+
"format",
370+
"is_remote",
371+
"lock",
372372
)
373373

374374
def __init__(

xarray/backends/zarr.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ def encode_zarr_attr_value(value):
182182

183183

184184
class ZarrArrayWrapper(BackendArray):
185-
__slots__ = ("dtype", "shape", "_array")
185+
__slots__ = ("_array", "dtype", "shape")
186186

187187
def __init__(self, zarr_array):
188188
# some callers attempt to evaluate an array if an `array` property exists on the object.
@@ -598,18 +598,18 @@ class ZarrStore(AbstractWritableDataStore):
598598
"""Store for reading and writing data via zarr"""
599599

600600
__slots__ = (
601-
"zarr_group",
602601
"_append_dim",
602+
"_close_store_on_close",
603603
"_consolidate_on_close",
604604
"_group",
605605
"_mode",
606606
"_read_only",
607-
"_synchronizer",
608-
"_write_region",
609607
"_safe_chunks",
610-
"_write_empty",
611-
"_close_store_on_close",
608+
"_synchronizer",
612609
"_use_zarr_fill_value_as_mask",
610+
"_write_empty",
611+
"_write_region",
612+
"zarr_group",
613613
)
614614

615615
@classmethod

xarray/core/computation.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,11 @@ class _UFuncSignature:
7777
"""
7878

7979
__slots__ = (
80-
"input_core_dims",
81-
"output_core_dims",
80+
"_all_core_dims",
8281
"_all_input_core_dims",
8382
"_all_output_core_dims",
84-
"_all_core_dims",
83+
"input_core_dims",
84+
"output_core_dims",
8585
)
8686

8787
def __init__(self, input_core_dims, output_core_dims=((),)):

xarray/core/dataarray.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -421,13 +421,13 @@ class DataArray(
421421
_variable: Variable
422422

423423
__slots__ = (
424+
"__weakref__",
424425
"_cache",
425-
"_coords",
426426
"_close",
427+
"_coords",
427428
"_indexes",
428429
"_name",
429430
"_variable",
430-
"__weakref__",
431431
)
432432

433433
dt = utils.UncachedAccessor(CombinedDatetimelikeAccessor["DataArray"])

xarray/core/dataset.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -684,15 +684,15 @@ class Dataset(
684684
_variables: dict[Hashable, Variable]
685685

686686
__slots__ = (
687+
"__weakref__",
687688
"_attrs",
688689
"_cache",
690+
"_close",
689691
"_coord_names",
690692
"_dims",
691693
"_encoding",
692-
"_close",
693694
"_indexes",
694695
"_variables",
695-
"__weakref__",
696696
)
697697

698698
def __init__(

xarray/core/datatree.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -217,10 +217,10 @@ class DatasetView(Dataset):
217217
__slots__ = (
218218
"_attrs",
219219
"_cache", # used by _CachedAccessor
220+
"_close",
220221
"_coord_names",
221222
"_dims",
222223
"_encoding",
223-
"_close",
224224
"_indexes",
225225
"_variables",
226226
)
@@ -457,17 +457,17 @@ class DataTree(
457457
_close: Callable[[], None] | None
458458

459459
__slots__ = (
460-
"_name",
461-
"_parent",
462-
"_children",
460+
"_attrs",
463461
"_cache", # used by _CachedAccessor
462+
"_children",
463+
"_close",
464464
"_data_variables",
465+
"_encoding",
466+
"_name",
465467
"_node_coord_variables",
466468
"_node_dims",
467469
"_node_indexes",
468-
"_attrs",
469-
"_encoding",
470-
"_close",
470+
"_parent",
471471
)
472472

473473
def __init__(

xarray/core/groupby.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ class _DummyGroup(Generic[T_Xarray]):
173173
Should not be user visible.
174174
"""
175175

176-
__slots__ = ("name", "coords", "size", "dataarray")
176+
__slots__ = ("coords", "dataarray", "name", "size")
177177

178178
def __init__(self, obj: T_Xarray, name: Hashable, coords) -> None:
179179
self.name = name
@@ -567,24 +567,24 @@ class GroupBy(Generic[T_Xarray]):
567567
"""
568568

569569
__slots__ = (
570+
"_by_chunked",
571+
"_codes",
572+
"_dims",
570573
"_group_dim",
571-
"groupers",
572-
"_obj",
573-
"_restore_coord_dims",
574574
# cached properties
575575
"_groups",
576-
"_dims",
577-
"_sizes",
576+
"_inserted_dims",
578577
"_len",
579-
"_by_chunked",
578+
"_obj",
580579
# Save unstacked object for flox
581580
"_original_obj",
582-
"_codes",
583-
# stack nD vars
584-
"group1d",
581+
"_restore_coord_dims",
582+
"_sizes",
585583
"_stacked_dim",
586-
"_inserted_dims",
587584
"encoded",
585+
# stack nD vars
586+
"group1d",
587+
"groupers",
588588
)
589589
_obj: T_Xarray
590590
groupers: tuple[ResolvedGrouper, ...]

xarray/core/indexes.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ class PandasIndex(Index):
573573
dim: Hashable
574574
coord_dtype: Any
575575

576-
__slots__ = ("index", "dim", "coord_dtype")
576+
__slots__ = ("coord_dtype", "dim", "index")
577577

578578
def __init__(
579579
self,
@@ -939,7 +939,7 @@ class PandasMultiIndex(PandasIndex):
939939
coord_dtype: Any
940940
level_coords_dtype: dict[str, Any]
941941

942-
__slots__ = ("index", "dim", "coord_dtype", "level_coords_dtype")
942+
__slots__ = ("coord_dtype", "dim", "index", "level_coords_dtype")
943943

944944
def __init__(self, array: Any, dim: Hashable, level_coords_dtype: Any = None):
945945
super().__init__(array, dim)
@@ -1451,13 +1451,13 @@ class Indexes(collections.abc.Mapping, Generic[T_PandasOrXarrayIndex]):
14511451
_variables: dict[Any, Variable]
14521452

14531453
__slots__ = (
1454+
"__coord_name_id",
1455+
"__id_coord_names",
1456+
"__id_index",
1457+
"_dims",
14541458
"_index_type",
14551459
"_indexes",
14561460
"_variables",
1457-
"_dims",
1458-
"__coord_name_id",
1459-
"__id_index",
1460-
"__id_coord_names",
14611461
)
14621462

14631463
def __init__(

xarray/core/indexing.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ def __getitem__(self, key: Any):
599599
class LazilyIndexedArray(ExplicitlyIndexedNDArrayMixin):
600600
"""Wrap an array to make basic and outer indexing lazy."""
601601

602-
__slots__ = ("array", "key", "_shape")
602+
__slots__ = ("_shape", "array", "key")
603603

604604
def __init__(self, array: Any, key: ExplicitIndexer | None = None):
605605
"""
@@ -779,7 +779,7 @@ def _wrap_numpy_scalars(array):
779779

780780

781781
class CopyOnWriteArray(ExplicitlyIndexedNDArrayMixin):
782-
__slots__ = ("array", "_copied")
782+
__slots__ = ("_copied", "array")
783783

784784
def __init__(self, array: duckarray[Any, Any]):
785785
self.array = as_indexable(array)
@@ -1658,7 +1658,7 @@ def transpose(self, order):
16581658
class PandasIndexingAdapter(ExplicitlyIndexedNDArrayMixin):
16591659
"""Wrap a pandas.Index to preserve dtypes and handle explicit indexing."""
16601660

1661-
__slots__ = ("array", "_dtype")
1661+
__slots__ = ("_dtype", "array")
16621662

16631663
array: pd.Index
16641664
_dtype: np.dtype
@@ -1825,7 +1825,7 @@ class PandasMultiIndexingAdapter(PandasIndexingAdapter):
18251825
the same multi-index).
18261826
"""
18271827

1828-
__slots__ = ("array", "_dtype", "level", "adapter")
1828+
__slots__ = ("_dtype", "adapter", "array", "level")
18291829

18301830
array: pd.MultiIndex
18311831
_dtype: np.dtype

xarray/core/rolling.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class Rolling(Generic[T_Xarray]):
6464
xarray.DataArray.rolling
6565
"""
6666

67-
__slots__ = ("obj", "window", "min_periods", "center", "dim")
67+
__slots__ = ("center", "dim", "min_periods", "obj", "window")
6868
_attributes = ("window", "min_periods", "center", "dim")
6969
dim: list[Hashable]
7070
window: list[int]
@@ -907,12 +907,12 @@ class Coarsen(CoarsenArithmetic, Generic[T_Xarray]):
907907
"""
908908

909909
__slots__ = (
910-
"obj",
911910
"boundary",
912911
"coord_func",
913-
"windows",
912+
"obj",
914913
"side",
915914
"trim_excess",
915+
"windows",
916916
)
917917
_attributes = ("windows", "side", "trim_excess")
918918
obj: T_Xarray

xarray/core/variable.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ class Variable(NamedArray, AbstractArray, VariableArithmetic):
379379
they can use more complete metadata in context of coordinate labels.
380380
"""
381381

382-
__slots__ = ("_dims", "_data", "_attrs", "_encoding")
382+
__slots__ = ("_attrs", "_data", "_dims", "_encoding")
383383

384384
def __init__(
385385
self,

xarray/namedarray/core.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ class NamedArray(NamedArrayAggregations, Generic[_ShapeType_co, _DType_co]):
248248
>>> narr = NamedArray(("x",), data, {"units": "m"}) # TODO: Better name than narr?
249249
"""
250250

251-
__slots__ = ("_data", "_dims", "_attrs")
251+
__slots__ = ("_attrs", "_data", "_dims")
252252

253253
_data: duckarray[Any, _DType_co]
254254
_dims: _Dims

xarray/plot/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1383,10 +1383,10 @@ class _Normalize(Sequence):
13831383

13841384
__slots__ = (
13851385
"_data",
1386+
"_data_is_numeric",
13861387
"_data_unique",
13871388
"_data_unique_index",
13881389
"_data_unique_inverse",
1389-
"_data_is_numeric",
13901390
"_width",
13911391
)
13921392

0 commit comments

Comments
 (0)