From 0b1aada10bbd8c4d99e035e8486e0a839a568418 Mon Sep 17 00:00:00 2001 From: Marco Gorelli <33491632+MarcoGorelli@users.noreply.github.com> Date: Thu, 14 Mar 2024 18:21:34 +0000 Subject: [PATCH] a bit less broken --- narwhals/dataframe.py | 1 - narwhals/expression.py | 8 +++++--- narwhals/pandas_like/utils.py | 5 +++-- narwhals/polars.py | 6 +++--- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/narwhals/dataframe.py b/narwhals/dataframe.py index eb86665f3..5a8ed4ee8 100644 --- a/narwhals/dataframe.py +++ b/narwhals/dataframe.py @@ -19,7 +19,6 @@ def extract_native(obj: Any, implementation: str) -> Any: - from narwhals.expression import PandasExpr from narwhals.series import Series # if isinstance(obj, NarwhalsExpr): diff --git a/narwhals/expression.py b/narwhals/expression.py index d38fdac40..288fd2ea9 100644 --- a/narwhals/expression.py +++ b/narwhals/expression.py @@ -1,11 +1,13 @@ from __future__ import annotations -from typing import Any, TYPE_CHECKING -from typing import Iterable, Callable +from typing import TYPE_CHECKING +from typing import Any +from typing import Callable +from typing import Iterable if TYPE_CHECKING: - from narwhals.polars import Expr from narwhals.pandas_like.expr import PandasExpr + from narwhals.polars import Expr def extract_native(expr: Expr, other: Any) -> Any: diff --git a/narwhals/pandas_like/utils.py b/narwhals/pandas_like/utils.py index ce54cc4ef..fa3eb6a6b 100644 --- a/narwhals/pandas_like/utils.py +++ b/narwhals/pandas_like/utils.py @@ -97,13 +97,14 @@ def parse_into_exprs( def parse_into_expr(implementation: str, into_expr: IntoExpr) -> PandasExpr: - from narwhals.expression import PandasExpr + from narwhals.expression import Expr + from narwhals.pandas_like.expr import PandasExpr from narwhals.pandas_like.namespace import Namespace from narwhals.pandas_like.series import PandasSeries plx = Namespace(implementation=implementation) - if isinstance(into_expr, PandasExpr): + if isinstance(into_expr, Expr): return into_expr._call(plx) if isinstance(into_expr, str): return plx.col(into_expr) diff --git a/narwhals/polars.py b/narwhals/polars.py index 72e0a81a5..30402c05e 100644 --- a/narwhals/polars.py +++ b/narwhals/polars.py @@ -26,11 +26,11 @@ def extract_native(obj: Any) -> Any: - from narwhals.expression import PandasExpr + from narwhals.expression import Expr - if isinstance(obj, PandasExpr): + if isinstance(obj, Expr): return obj._call(pl) - if isinstance(obj, PandasExpr): + if isinstance(obj, PolarsExpr): return obj._expr if isinstance(obj, DType): return obj._dtype