File tree 3 files changed +10
-9
lines changed
3 files changed +10
-9
lines changed Original file line number Diff line number Diff line change 1
1
# ruff: noqa
2
- # type: ignore
3
- from typing import Any
2
+ from typing import Any , TYPE_CHECKING , TypeVar
4
3
import pandas as pd
5
4
import polars as pl
6
5
7
6
import narwhals as nw
8
7
8
+ T = TypeVar ("T" )
9
+
9
10
10
11
def my_agnostic_function (
11
- suppliers_native : nw . typing . T ,
12
- parts_native : nw . typing . T ,
13
- ) -> nw . typing . T :
12
+ suppliers_native : T ,
13
+ parts_native : T ,
14
+ ) -> T :
14
15
suppliers = nw .DataFrame (suppliers_native )
15
16
parts = nw .DataFrame (parts_native )
16
17
Original file line number Diff line number Diff line change 26
26
class DataFrame (Generic [T ]):
27
27
def __init__ (
28
28
self ,
29
- df : Any ,
29
+ df : T ,
30
30
* ,
31
31
is_eager : bool = False ,
32
32
is_lazy : bool = False ,
@@ -35,7 +35,7 @@ def __init__(
35
35
self ._is_eager = is_eager
36
36
self ._is_lazy = is_lazy
37
37
if implementation is not None :
38
- self ._dataframe = df
38
+ self ._dataframe : Any = df
39
39
self ._implementation = implementation
40
40
return
41
41
if (pl := get_polars ()) is not None and isinstance (
Original file line number Diff line number Diff line change 15
15
class Series (Generic [T ]):
16
16
def __init__ (
17
17
self ,
18
- series : Any ,
18
+ series : T ,
19
19
* ,
20
20
implementation : str | None = None ,
21
21
) -> None :
22
22
from narwhals .pandas_like .series import PandasSeries
23
23
24
24
if implementation is not None :
25
- self ._series = series
25
+ self ._series : Any = series
26
26
self ._implementation = implementation
27
27
return
28
28
if (pl := get_polars ()) is not None and isinstance (series , pl .Series ):
You can’t perform that action at this time.
0 commit comments