Repository: narwhals-dev/narwhals
Pull request #1490 (2024-12-03 07:51:16)

chore: rename _change_dtypes to _change_version
<!--
# Thanks for contributing a pull request! 
## Please make sure you see our contribution guidelines: https://github.com/narwhals-dev/narwhals/blob/main/CONTRIBUTING.md
-->

## What type of PR is this? (check all applicable)

- [ ] 💾 Refactor
- [ ] ✨ Feature
- [ ] 🐛 Bug Fix
- [ ] 🔧 Optimization
- [ ] 📝 Documentation
- [ ] ✅ Test
- [ ] 🐳 Other

## Related issues

- Related issue #\<issue number\>
- Closes #\<issue number\>

## Checklist

- [ ] Code follows style guide (ruff)
- [ ] Tests added
- [ ] Documented the changes

## If you have comments or can explain your changes, please do so below



Patch:
diff --git a/narwhals/_arrow/dataframe.py b/narwhals/_arrow/dataframe.py
index 3f8f96be..139a865b 100644
--- a/narwhals/_arrow/dataframe.py
+++ b/narwhals/_arrow/dataframe.py
@@ -72,7 +72,7 @@ class ArrowDataFrame:
     def __narwhals_lazyframe__(self: Self) -> Self:
         return self
 
-    def _change_dtypes(self: Self, version: Version) -> Self:
+    def _change_version(self: Self, version: Version) -> Self:
         return self.__class__(
             self._native_frame, backend_version=self._backend_version, version=version
         )
diff --git a/narwhals/_arrow/series.py b/narwhals/_arrow/series.py
index 336a7b1f..021cc075 100644
--- a/narwhals/_arrow/series.py
+++ b/narwhals/_arrow/series.py
@@ -53,7 +53,7 @@ class ArrowSeries:
         self._backend_version = backend_version
         self._version = version
 
-    def _change_dtypes(self: Self, version: Version) -> Self:
+    def _change_version(self: Self, version: Version) -> Self:
         return self.__class__(
             self._native_series,
             name=self._name,
diff --git a/narwhals/_dask/dataframe.py b/narwhals/_dask/dataframe.py
index ccdb735a..98f7745a 100644
--- a/narwhals/_dask/dataframe.py
+++ b/narwhals/_dask/dataframe.py
@@ -59,7 +59,7 @@ class DaskLazyFrame:
     def __narwhals_lazyframe__(self) -> Self:
         return self
 
-    def _change_dtypes(self, version: Version) -> Self:
+    def _change_version(self, version: Version) -> Self:
         return self.__class__(
             self._native_frame, backend_version=self._backend_version, version=version
         )
diff --git a/narwhals/_duckdb/dataframe.py b/narwhals/_duckdb/dataframe.py
index 59329c73..fd1c436e 100644
--- a/narwhals/_duckdb/dataframe.py
+++ b/narwhals/_duckdb/dataframe.py
@@ -141,7 +141,7 @@ class DuckDBInterchangeFrame:
     def to_arrow(self: Self) -> pa.Table:
         return self._native_frame.arrow()
 
-    def _change_dtypes(self: Self, version: Version) -> Self:
+    def _change_version(self: Self, version: Version) -> Self:
         return self.__class__(self._native_frame, version=version)
 
     def _from_native_frame(self: Self, df: Any) -> Self:
diff --git a/narwhals/_ibis/dataframe.py b/narwhals/_ibis/dataframe.py
index 0c679f18..454354a7 100644
--- a/narwhals/_ibis/dataframe.py
+++ b/narwhals/_ibis/dataframe.py
@@ -121,7 +121,7 @@ class IbisInterchangeFrame:
         )
         raise NotImplementedError(msg)
 
-    def _change_dtypes(self: Self, version: Version) -> Self:
+    def _change_version(self: Self, version: Version) -> Self:
         return self.__class__(self._native_frame, version=version)
 
     def _from_native_frame(self: Self, df: Any) -> Self:
diff --git a/narwhals/_interchange/dataframe.py b/narwhals/_interchange/dataframe.py
index d1fccf0a..562ee074 100644
--- a/narwhals/_interchange/dataframe.py
+++ b/narwhals/_interchange/dataframe.py
@@ -88,7 +88,7 @@ class InterchangeFrame:
         self._interchange_frame = df.__dataframe__()
         self._version = version
 
-    def _change_dtypes(self: Self, version: Version) -> Self:
+    def _change_version(self: Self, version: Version) -> Self:
         return self.__class__(
             WrapInterchangeFrame(self._interchange_frame), version=version
         )
diff --git a/narwhals/_pandas_like/dataframe.py b/narwhals/_pandas_like/dataframe.py
index f365e9c3..d9c47a18 100644
--- a/narwhals/_pandas_like/dataframe.py
+++ b/narwhals/_pandas_like/dataframe.py
@@ -101,7 +101,7 @@ class PandasLikeDataFrame:
             msg = f"Expected unique column names, got:{msg}"
             raise ValueError(msg)
 
-    def _change_dtypes(self, version: Version) -> Self:
+    def _change_version(self, version: Version) -> Self:
         return self.__class__(
             self._native_frame,
             implementation=self._implementation,
diff --git a/narwhals/_pandas_like/series.py b/narwhals/_pandas_like/series.py
index 9c95c146..e6d4b91e 100644
--- a/narwhals/_pandas_like/series.py
+++ b/narwhals/_pandas_like/series.py
@@ -116,7 +116,7 @@ class PandasLikeSeries:
             return self._native_series.iloc[idx]
         return self._from_native_series(self._native_series.iloc[idx])
 
-    def _change_dtypes(self, version: Version) -> Self:
+    def _change_version(self, version: Version) -> Self:
         return self.__class__(
             self._native_series,
             implementation=self._implementation,
diff --git a/narwhals/_polars/dataframe.py b/narwhals/_polars/dataframe.py
index d2e2657c..bf3e1cc2 100644
--- a/narwhals/_polars/dataframe.py
+++ b/narwhals/_polars/dataframe.py
@@ -64,7 +64,7 @@ class PolarsDataFrame:
         msg = f"Expected polars, got: {type(self._implementation)}"  # pragma: no cover
         raise AssertionError(msg)
 
-    def _change_dtypes(self: Self, version: Version) -> Self:
+    def _change_version(self: Self, version: Version) -> Self:
         return self.__class__(
             self._native_frame, backend_version=self._backend_version, version=version
         )
@@ -369,7 +369,7 @@ class PolarsLazyFrame:
             df, backend_version=self._backend_version, version=self._version
         )
 
-    def _change_dtypes(self: Self, version: Version) -> Self:
+    def _change_version(self: Self, version: Version) -> Self:
         return self.__class__(
             self._native_frame, backend_version=self._backend_version, version=version
         )
diff --git a/narwhals/_polars/series.py b/narwhals/_polars/series.py
index e546f031..9ba18e2f 100644
--- a/narwhals/_polars/series.py
+++ b/narwhals/_polars/series.py
@@ -52,7 +52,7 @@ class PolarsSeries:
         msg = f"Expected polars, got: {type(self._implementation)}"  # pragma: no cover
         raise AssertionError(msg)
 
-    def _change_dtypes(self: Self, version: Version) -> Self:
+    def _change_version(self: Self, version: Version) -> Self:
         return self.__class__(
             self._native_series, backend_version=self._backend_version, version=version
         )
diff --git a/narwhals/stable/v1/__init__.py b/narwhals/stable/v1/__init__.py
index 39dab17a..80b3cc75 100644
--- a/narwhals/stable/v1/__init__.py
+++ b/narwhals/stable/v1/__init__.py
@@ -1166,17 +1166,17 @@ def _stableify(
 ) -> DataFrame[IntoFrameT] | LazyFrame[IntoFrameT] | Series | Expr | Any:
     if isinstance(obj, NwDataFrame):
         return DataFrame(
-            obj._compliant_frame._change_dtypes(Version.V1),
+            obj._compliant_frame._change_version(Version.V1),
             level=obj._level,
         )
     if isinstance(obj, NwLazyFrame):
         return LazyFrame(
-            obj._compliant_frame._change_dtypes(Version.V1),
+            obj._compliant_frame._change_version(Version.V1),
             level=obj._level,
         )
     if isinstance(obj, NwSeries):
         return Series(
-            obj._compliant_series._change_dtypes(Version.V1),
+            obj._compliant_series._change_version(Version.V1),
             level=obj._level,
         )
     if isinstance(obj, NwExpr):


Test patch:
diff --git a/tests/translate/from_native_test.py b/tests/translate/from_native_test.py
index 307589f9..7092ca7c 100644
--- a/tests/translate/from_native_test.py
+++ b/tests/translate/from_native_test.py
@@ -32,7 +32,7 @@ series_pa = pa.chunked_array([data["a"]])
 
 
 class MockDataFrame:
-    def _change_dtypes(self, _version: Version) -> MockDataFrame:
+    def _change_version(self, _version: Version) -> MockDataFrame:
         return self
 
     def __narwhals_dataframe__(self) -> Any:
@@ -40,7 +40,7 @@ class MockDataFrame:
 
 
 class MockLazyFrame:
-    def _change_dtypes(self, _version: Version) -> MockLazyFrame:
+    def _change_version(self, _version: Version) -> MockLazyFrame:
         return self
 
     def __narwhals_lazyframe__(self) -> Any:
@@ -48,7 +48,7 @@ class MockLazyFrame:
 
 
 class MockSeries:
-    def _change_dtypes(self, _version: Version) -> MockSeries:
+    def _change_version(self, _version: Version) -> MockSeries:
         return self
 
     def __narwhals_series__(self) -> Any: