Skip to content

Commit

Permalink
a bit less broken
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoGorelli committed Mar 14, 2024
1 parent d80ac61 commit 0b1aada
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
1 change: 0 additions & 1 deletion narwhals/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
8 changes: 5 additions & 3 deletions narwhals/expression.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
5 changes: 3 additions & 2 deletions narwhals/pandas_like/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions narwhals/polars.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0b1aada

Please sign in to comment.