Skip to content

Commit 4014ac3

Browse files
authored
chore: invert version.V1 conditions (#2812)
chore: invert version.V1 conditions
1 parent 8afbeec commit 4014ac3

File tree

3 files changed

+32
-34
lines changed

3 files changed

+32
-34
lines changed

narwhals/_duckdb/dataframe.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,11 @@ def from_native(
9292
def to_narwhals(
9393
self, *args: Any, **kwds: Any
9494
) -> LazyFrame[duckdb.DuckDBPyRelation] | DataFrameV1[duckdb.DuckDBPyRelation]:
95-
if self._version is Version.MAIN:
96-
return self._version.lazyframe(self, level="lazy")
95+
if self._version is Version.V1:
96+
from narwhals.stable.v1 import DataFrame as DataFrameV1
9797

98-
from narwhals.stable.v1 import DataFrame as DataFrameV1
99-
100-
return DataFrameV1(self, level="interchange") # type: ignore[no-any-return]
98+
return DataFrameV1(self, level="interchange") # type: ignore[no-any-return]
99+
return self._version.lazyframe(self, level="lazy")
101100

102101
def __narwhals_dataframe__(self) -> Self: # pragma: no cover
103102
# Keep around for backcompat.

narwhals/_ibis/dataframe.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,11 @@ def from_native(cls, data: ir.Table, /, *, context: _LimitedContext) -> Self:
6767
return cls(data, version=context._version)
6868

6969
def to_narwhals(self) -> LazyFrame[ir.Table] | DataFrameV1[ir.Table]:
70-
if self._version is Version.MAIN:
71-
return self._version.lazyframe(self, level="lazy")
70+
if self._version is Version.V1:
71+
from narwhals.stable.v1 import DataFrame
7272

73-
from narwhals.stable.v1 import DataFrame as DataFrameV1
74-
75-
return DataFrameV1(self, level="interchange")
73+
return DataFrame(self, level="interchange")
74+
return self._version.lazyframe(self, level="lazy")
7675

7776
def __narwhals_dataframe__(self) -> Self: # pragma: no cover
7877
# Keep around for backcompat.

narwhals/_utils.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -216,53 +216,53 @@ class Version(Enum):
216216

217217
@property
218218
def namespace(self) -> type[Namespace[Any]]:
219-
if self is Version.MAIN:
220-
from narwhals._namespace import Namespace
219+
if self is Version.V1:
220+
from narwhals.stable.v1._namespace import Namespace as NamespaceV1
221221

222-
return Namespace
223-
from narwhals.stable.v1._namespace import Namespace
222+
return NamespaceV1
223+
from narwhals._namespace import Namespace
224224

225225
return Namespace
226226

227227
@property
228228
def dtypes(self) -> DTypes:
229-
if self is Version.MAIN:
230-
from narwhals import dtypes
229+
if self is Version.V1:
230+
from narwhals.stable.v1 import dtypes as dtypes_v1
231231

232-
return dtypes
233-
from narwhals.stable.v1 import dtypes as v1_dtypes
232+
return dtypes_v1
233+
from narwhals import dtypes
234234

235-
return v1_dtypes
235+
return dtypes
236236

237237
@property
238238
def dataframe(self) -> type[DataFrame[Any]]:
239-
if self is Version.MAIN:
240-
from narwhals.dataframe import DataFrame
239+
if self is Version.V1:
240+
from narwhals.stable.v1 import DataFrame as DataFrameV1
241241

242-
return DataFrame
243-
from narwhals.stable.v1 import DataFrame as DataFrameV1
242+
return DataFrameV1
243+
from narwhals.dataframe import DataFrame
244244

245-
return DataFrameV1
245+
return DataFrame
246246

247247
@property
248248
def lazyframe(self) -> type[LazyFrame[Any]]:
249-
if self is Version.MAIN:
250-
from narwhals.dataframe import LazyFrame
249+
if self is Version.V1:
250+
from narwhals.stable.v1 import LazyFrame as LazyFrameV1
251251

252-
return LazyFrame
253-
from narwhals.stable.v1 import LazyFrame as LazyFrameV1
252+
return LazyFrameV1
253+
from narwhals.dataframe import LazyFrame
254254

255-
return LazyFrameV1
255+
return LazyFrame
256256

257257
@property
258258
def series(self) -> type[Series[Any]]:
259-
if self is Version.MAIN:
260-
from narwhals.series import Series
259+
if self is Version.V1:
260+
from narwhals.stable.v1 import Series as SeriesV1
261261

262-
return Series
263-
from narwhals.stable.v1 import Series as SeriesV1
262+
return SeriesV1
263+
from narwhals.series import Series
264264

265-
return SeriesV1
265+
return Series
266266

267267

268268
class Implementation(NoAutoEnum):

0 commit comments

Comments
 (0)