Skip to content

Commit 91a0fd4

Browse files
committed
rollback typing changes... as I cannot recall their reason
1 parent e18ca1c commit 91a0fd4

3 files changed

Lines changed: 11 additions & 21 deletions

File tree

src/narwhals/stable/v1/typing.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,7 @@
88
if TYPE_CHECKING:
99
from typing import TypeAlias
1010

11-
from narwhals._native import (
12-
NativeDataFrame,
13-
NativeDuckDB,
14-
NativeIbis,
15-
NativeLazyFrame,
16-
)
11+
from narwhals._native import NativeDataFrame, NativeDuckDB, NativeLazyFrame
1712
from narwhals.stable.v1 import DataFrame, Expr, LazyFrame, Series
1813

1914
class DataFrameLike(Protocol):
@@ -30,9 +25,7 @@ def __dataframe__(self, *args: Any, **kwargs: Any) -> Any: ...
3025
`nw.Expr`, e.g. `df.select('a')`.
3126
"""
3227

33-
IntoDataFrame: TypeAlias = Union[
34-
"NativeDataFrame", "DataFrameLike", "NativeDuckDB", "NativeIbis"
35-
]
28+
IntoDataFrame: TypeAlias = Union["NativeDataFrame", "DataFrameLike", "NativeDuckDB"]
3629
"""Anything which can be converted to a Narwhals DataFrame.
3730
3831
Use this if your function accepts a narwhalifiable object but doesn't care about its backend.

src/narwhals/testing/asserts/frame.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
if TYPE_CHECKING:
1515
from narwhals._typing import Arrow, IntoBackend, Pandas, Polars
16+
from narwhals.typing import DataFrameT, LazyFrameT
1617

1718
GUARANTEES_ROW_ORDER = {
1819
Implementation.PANDAS,
@@ -25,8 +26,8 @@
2526

2627

2728
def assert_frame_equal(
28-
left: DataFrame[Any] | LazyFrame[Any],
29-
right: DataFrame[Any] | LazyFrame[Any],
29+
left: DataFrameT | LazyFrameT,
30+
right: DataFrameT | LazyFrameT,
3031
*,
3132
check_row_order: bool = True,
3233
check_column_order: bool = True,
@@ -144,8 +145,8 @@ def assert_frame_equal(
144145

145146

146147
def _check_correct_input_type( # noqa: RET503
147-
left: DataFrame[Any] | LazyFrame[Any],
148-
right: DataFrame[Any] | LazyFrame[Any],
148+
left: DataFrameT | LazyFrameT,
149+
right: DataFrameT | LazyFrameT,
149150
backend: IntoBackend[Polars | Pandas | Arrow] | None,
150151
) -> tuple[DataFrame[Any], DataFrame[Any]]:
151152
# Adapted from https://github.com/pola-rs/polars/blob/afdbf3056d1228cf493901e45f536b0905cec8ea/py-polars/src/polars/testing/asserts/frame.py#L15-L17
@@ -164,8 +165,8 @@ def _check_correct_input_type( # noqa: RET503
164165

165166

166167
def _assert_dataframe_equal(
167-
left: DataFrame[Any],
168-
right: DataFrame[Any],
168+
left: DataFrameT,
169+
right: DataFrameT,
169170
impl: Implementation,
170171
*,
171172
check_row_order: bool,
@@ -231,11 +232,7 @@ def _assert_dataframe_equal(
231232

232233

233234
def _check_schema_equal(
234-
left: DataFrame[Any],
235-
right: DataFrame[Any],
236-
*,
237-
check_dtypes: bool,
238-
check_column_order: bool,
235+
left: DataFrameT, right: DataFrameT, *, check_dtypes: bool, check_column_order: bool
239236
) -> None:
240237
"""Compares DataFrame schema based on specified criteria.
241238

tests/testing/assert_frame_equal_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def test_implementation_mismatch() -> None:
4141
import pyarrow as pa
4242

4343
with _assertion_error("implementation mismatch"):
44-
assert_frame_equal(
44+
assert_frame_equal( # type: ignore[type-var]
4545
nw.from_native(pd.DataFrame({"a": [1]})), nw.from_native(pa.table({"a": [1]}))
4646
)
4747

0 commit comments

Comments
 (0)