diff --git a/f.py b/f.py index 0cc009b81..f9b0eb678 100644 --- a/f.py +++ b/f.py @@ -1,16 +1,17 @@ # ruff: noqa -# type: ignore -from typing import Any +from typing import Any, TYPE_CHECKING, TypeVar import pandas as pd import polars as pl import narwhals as nw +T = TypeVar("T") + def my_agnostic_function( - suppliers_native: nw.typing.T, - parts_native: nw.typing.T, -) -> nw.typing.T: + suppliers_native: T, + parts_native: T, +) -> T: suppliers = nw.DataFrame(suppliers_native) parts = nw.DataFrame(parts_native) diff --git a/narwhals/dataframe.py b/narwhals/dataframe.py index b6d7131b0..015360961 100644 --- a/narwhals/dataframe.py +++ b/narwhals/dataframe.py @@ -26,7 +26,7 @@ class DataFrame(Generic[T]): def __init__( self, - df: Any, + df: T, *, is_eager: bool = False, is_lazy: bool = False, @@ -35,7 +35,7 @@ def __init__( self._is_eager = is_eager self._is_lazy = is_lazy if implementation is not None: - self._dataframe = df + self._dataframe: Any = df self._implementation = implementation return if (pl := get_polars()) is not None and isinstance( diff --git a/narwhals/series.py b/narwhals/series.py index 570c90aea..068c8475b 100644 --- a/narwhals/series.py +++ b/narwhals/series.py @@ -15,14 +15,14 @@ class Series(Generic[T]): def __init__( self, - series: Any, + series: T, *, implementation: str | None = None, ) -> None: from narwhals.pandas_like.series import PandasSeries if implementation is not None: - self._series = series + self._series: Any = series self._implementation = implementation return if (pl := get_polars()) is not None and isinstance(series, pl.Series):