diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e19b55ed562..217c60e7098 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -24,7 +24,7 @@ repos: - id: rst-inline-touching-normal - id: text-unicode-replacement-char - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.15.4 + rev: v0.15.9 hooks: - id: ruff-check args: ["--fix", "--show-fixes"] @@ -42,7 +42,7 @@ repos: - id: prettier args: ["--cache-location=.prettier_cache/cache"] - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.19.1 + rev: v1.20.0 hooks: - id: mypy # Copied from setup.cfg @@ -76,7 +76,7 @@ repos: - id: validate-pyproject additional_dependencies: ["validate-pyproject-schema-store[all]"] - repo: https://github.com/adhtruong/mirrors-typos - rev: v1.44.0 + rev: v1.45.0 hooks: - id: typos - repo: https://github.com/zizmorcore/zizmor-pre-commit diff --git a/xarray/backends/writers.py b/xarray/backends/writers.py index a01f4f3b835..9e4baa8745b 100644 --- a/xarray/backends/writers.py +++ b/xarray/backends/writers.py @@ -38,7 +38,7 @@ T_DataTreeNetcdfTypes = Literal["NETCDF4"] -WRITEABLE_STORES: dict[T_NetcdfEngine, Callable] = { +WRITABLE_STORES: dict[T_NetcdfEngine, Callable] = { "netcdf4": backends.NetCDF4DataStore.open, "scipy": backends.ScipyDataStore, "h5netcdf": backends.H5NetCDFStore.open, @@ -57,7 +57,7 @@ def get_writable_netcdf_store( ) -> AbstractWritableDataStore: """Create a store for writing to a netCDF file.""" try: - store_open = WRITEABLE_STORES[engine] + store_open = WRITABLE_STORES[engine] except KeyError as err: raise ValueError(f"unrecognized engine for to_netcdf: {engine!r}") from err diff --git a/xarray/compat/dask_array_compat.py b/xarray/compat/dask_array_compat.py index b8c7da3e64f..0b6371e6978 100644 --- a/xarray/compat/dask_array_compat.py +++ b/xarray/compat/dask_array_compat.py @@ -20,7 +20,7 @@ def sliding_window_view( x, window_shape, axis=None, *, automatic_rechunk=True, **kwargs ): # Backcompat for handling `automatic_rechunk`, delete when dask>=2024.11.0 - # Note that subok, writeable are unsupported by dask, so we ignore those in kwargs + # Note that subok, writable are unsupported by dask, so we ignore those in kwargs from dask.array.lib.stride_tricks import sliding_window_view if module_available("dask", "2024.11.0"): diff --git a/xarray/computation/rolling.py b/xarray/computation/rolling.py index 0f914691211..1e62fcdb823 100644 --- a/xarray/computation/rolling.py +++ b/xarray/computation/rolling.py @@ -359,8 +359,8 @@ def construct( Returns ------- DataArray - a view of the original array. By default, the returned array is not writeable. - For numpy arrays, one can pass ``writeable=True`` in ``sliding_window_view_kwargs``. + a view of the original array. By default, the returned array is not writable. + For numpy arrays, one can pass ``writable=True`` in ``sliding_window_view_kwargs``. See Also -------- @@ -954,8 +954,8 @@ def construct( Returns ------- Dataset - Dataset with views of the original arrays. By default, the returned arrays are not writeable. - For numpy arrays, one can pass ``writeable=True`` in ``sliding_window_view_kwargs``. + Dataset with views of the original arrays. By default, the returned arrays are not writable. + For numpy arrays, one can pass ``writable=True`` in ``sliding_window_view_kwargs``. See Also -------- diff --git a/xarray/core/duck_array_ops.py b/xarray/core/duck_array_ops.py index e10ab5a3558..9df4779a876 100644 --- a/xarray/core/duck_array_ops.py +++ b/xarray/core/duck_array_ops.py @@ -142,7 +142,7 @@ def sliding_window_view(array, window_shape, axis=None, **kwargs): eager_module=xp.lib.stride_tricks, dask_module=dask_array_compat, dask_only_kwargs=("automatic_rechunk",), - numpy_only_kwargs=("subok", "writeable"), + numpy_only_kwargs=("subok", "writable"), ) return func(array, window_shape, axis=axis, **kwargs) diff --git a/xarray/core/indexing.py b/xarray/core/indexing.py index bb12704e55c..a78cfc8a9f6 100644 --- a/xarray/core/indexing.py +++ b/xarray/core/indexing.py @@ -1720,7 +1720,7 @@ def _safe_setitem(self, array, key: tuple[Any, ...], value: Any) -> None: array[key] = value except ValueError as exc: # More informative exception if read-only view - if not array.flags.writeable and not array.flags.owndata: + if not array.flags.writable and not array.flags.owndata: raise ValueError( "Assignment destination is a view. " "Do you want to .copy() array first?" diff --git a/xarray/core/variable.py b/xarray/core/variable.py index 750fff0bd67..8b6ecc82840 100644 --- a/xarray/core/variable.py +++ b/xarray/core/variable.py @@ -222,10 +222,10 @@ def _possibly_convert_objects(values): """ as_series = pd.Series(values.ravel(), copy=False) result = np.asarray(as_series).reshape(values.shape) - if not result.flags.writeable: + if not result.flags.writable: # GH8843, pandas copy-on-write mode creates read-only arrays by default try: - result.flags.writeable = True + result.flags.writable = True except ValueError: result = result.copy() # For why we need this behavior: https://github.com/pandas-dev/pandas/issues/61938 @@ -1479,7 +1479,7 @@ def set_dims(self, dim, shape=None): if self.dims == expanded_dims: # don't use broadcast_to unless necessary so the result remains - # writeable if possible + # writable if possible expanded_data = self._data elif shape is None or all( s == 1 for s, e in zip(shape, dim, strict=True) if e not in self_dims diff --git a/xarray/tests/__init__.py b/xarray/tests/__init__.py index 3abb29f74bf..79edf4b28d3 100644 --- a/xarray/tests/__init__.py +++ b/xarray/tests/__init__.py @@ -57,7 +57,7 @@ ) -def assert_writeable(ds): +def assert_writable(ds): readonly = [ name for name, var in ds.variables.items() @@ -65,7 +65,7 @@ def assert_writeable(ds): and not isinstance( var.data, PandasExtensionArray | pd.api.extensions.ExtensionArray ) - and not var.data.flags.writeable + and not var.data.flags.writable ] assert not readonly, readonly @@ -439,7 +439,7 @@ def create_test_data( numbers_values = rs.integers(0, 3, _dims["dim3"], dtype="int64") obj.coords["numbers"] = ("dim3", numbers_values) obj.encoding = {"foo": "bar"} - assert_writeable(obj) + assert_writable(obj) return obj diff --git a/xarray/tests/test_dataset.py b/xarray/tests/test_dataset.py index 6be6c75dc5f..4e8507a0ede 100644 --- a/xarray/tests/test_dataset.py +++ b/xarray/tests/test_dataset.py @@ -59,7 +59,7 @@ assert_equal, assert_identical, assert_no_warnings, - assert_writeable, + assert_writable, create_test_data, has_cftime, has_dask, @@ -163,9 +163,9 @@ def create_append_test_data(seed=None) -> tuple[Dataset, Dataset, Dataset]: } ) - assert_writeable(ds) - assert_writeable(ds_to_append) - assert_writeable(ds_with_new_var) + assert_writable(ds) + assert_writable(ds_to_append) + assert_writable(ds_with_new_var) return ds, ds_to_append, ds_with_new_var @@ -178,8 +178,8 @@ def make_datasets(data, data_to_append) -> tuple[Dataset, Dataset]: ds_to_append = xr.Dataset( {"temperature": (["time"], data_to_append)}, coords={"time": [0, 1, 2]} ) - assert_writeable(ds) - assert_writeable(ds_to_append) + assert_writable(ds) + assert_writable(ds_to_append) return ds, ds_to_append u2_strings = ["ab", "cd", "ef"] diff --git a/xarray/tests/test_rolling.py b/xarray/tests/test_rolling.py index b4f9f45ea52..1664c18fa63 100644 --- a/xarray/tests/test_rolling.py +++ b/xarray/tests/test_rolling.py @@ -630,13 +630,13 @@ def test_rolling_construct_automatic_rechunk(self): rechunked = obj.rolling(time=100, center=True).construct( "window", sliding_window_view_kwargs=dict( - automatic_rechunk=True, writeable=False + automatic_rechunk=True, writable=False ), ) not_rechunked = obj.rolling(time=100, center=True).construct( "window", sliding_window_view_kwargs=dict( - automatic_rechunk=False, writeable=True + automatic_rechunk=False, writable=True ), ) assert rechunked.chunksizes != not_rechunked.chunksizes diff --git a/xarray/tests/test_variable.py b/xarray/tests/test_variable.py index 1ef6adc9caf..d91fd2b8582 100644 --- a/xarray/tests/test_variable.py +++ b/xarray/tests/test_variable.py @@ -73,15 +73,15 @@ def var(): np.array(["2019-01-01", "2019-01-02", "2019-01-03"], dtype="datetime64[ns]"), ], ) -def test_as_compatible_data_writeable(data): +def test_as_compatible_data_writable(data): # In pandas 3 the mode.copy_on_write option defaults to True, so the option # setting logic can be removed once our minimum version of pandas is # greater than or equal to 3. if not has_pandas_3: pd.set_option("mode.copy_on_write", True) - # GH8843, ensure writeable arrays for data_vars even with + # GH8843, ensure writable arrays for data_vars even with # pandas copy-on-write mode - assert as_compatible_data(data).flags.writeable + assert as_compatible_data(data).flags.writable if not has_pandas_3: pd.reset_option("mode.copy_on_write") @@ -2767,7 +2767,7 @@ def test_masked_array(self): assert np.dtype(float) == actual.dtype original2: Any = np.ma.MaskedArray([1.0, 2.0], mask=[True, False]) - original2.flags.writeable = False + original2.flags.writable = False expected2: Any = [np.nan, 2.0] actual = as_compatible_data(original2) assert_array_equal(expected2, actual)