Skip to content

Commit d050c65

Browse files
committed
chore(typing): fix [type-arg]
1 parent 4c8bbf5 commit d050c65

File tree

11 files changed

+21
-18
lines changed

11 files changed

+21
-18
lines changed

narwhals/_arrow/series.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -381,10 +381,12 @@ def __narwhals_series__(self: Self) -> Self:
381381
def __getitem__(self: Self, idx: int) -> Any: ...
382382

383383
@overload
384-
def __getitem__(self: Self, idx: slice | Sequence[int] | pa.ChunkedArray) -> Self: ...
384+
def __getitem__(
385+
self: Self, idx: slice | Sequence[int] | ArrowChunkedArray
386+
) -> Self: ...
385387

386388
def __getitem__(
387-
self: Self, idx: int | slice | Sequence[int] | pa.ChunkedArray
389+
self: Self, idx: int | slice | Sequence[int] | ArrowChunkedArray
388390
) -> Any | Self:
389391
if isinstance(idx, int):
390392
return maybe_extract_py_scalar(
@@ -690,7 +692,7 @@ def to_frame(self: Self) -> ArrowDataFrame:
690692
validate_column_names=False,
691693
)
692694

693-
def to_pandas(self: Self) -> pd.Series:
695+
def to_pandas(self: Self) -> pd.Series[Any]:
694696
import pandas as pd # ignore-banned-import()
695697

696698
return pd.Series(self._native_series, name=self.name) # pyright: ignore[reportArgumentType, reportCallIssue]

narwhals/_arrow/series_str.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import string
44
from typing import TYPE_CHECKING
5+
from typing import Any
56

67
import pyarrow.compute as pc
78

@@ -75,7 +76,7 @@ def to_datetime(self: Self, format: str | None) -> ArrowSeries: # noqa: A002
7576
native = self._compliant_series._native_series
7677
format = parse_datetime_format(native) if format is None else format
7778
strptime: Incomplete = pc.strptime
78-
timestamp_array: pa.Array[pa.TimestampScalar] = strptime(
79+
timestamp_array: pa.Array[pa.TimestampScalar[Any, Any]] = strptime(
7980
native, format=format, unit="us"
8081
)
8182
return self._compliant_series._from_native_series(timestamp_array)

narwhals/_expression_parsing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ def infer_kind(obj: IntoExpr | _1DArray | object, *, str_as_lit: bool) -> ExprKi
467467

468468

469469
def apply_n_ary_operation(
470-
plx: CompliantNamespace,
470+
plx: CompliantNamespace[Any, Any],
471471
function: Any,
472472
*comparands: IntoExpr,
473473
str_as_lit: bool,

narwhals/_pandas_like/dataframe.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
from narwhals.typing import CompliantDataFrame
5858
from narwhals.typing import CompliantLazyFrame
5959

60-
CLASSICAL_NUMPY_DTYPES: frozenset[np.dtype] = frozenset(
60+
CLASSICAL_NUMPY_DTYPES: frozenset[np.dtype[Any]] = frozenset(
6161
[
6262
np.dtype("float64"),
6363
np.dtype("float32"),

narwhals/_pandas_like/series.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ def to_numpy(self: Self, dtype: Any = None, copy: bool | None = None) -> _1DArra
681681
)
682682
return s.to_numpy(dtype=dtype, copy=copy)
683683

684-
def to_pandas(self: Self) -> pd.Series:
684+
def to_pandas(self: Self) -> pd.Series[Any]:
685685
if self._implementation is Implementation.PANDAS:
686686
return self._native_series
687687
elif self._implementation is Implementation.CUDF: # pragma: no cover

narwhals/_pandas_like/utils.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ def int_dtype_mapper(dtype: Any) -> str:
698698

699699

700700
def convert_str_slice_to_int_slice(
701-
str_slice: slice, columns: pd.Index
701+
str_slice: slice, columns: pd.Index[str]
702702
) -> tuple[int | None, int | None, int | None]:
703703
# We can safely cast to int because we know that `columns` doesn't contain duplicates.
704704
start = (
@@ -716,8 +716,8 @@ def convert_str_slice_to_int_slice(
716716

717717

718718
def calculate_timestamp_datetime(
719-
s: pd.Series, original_time_unit: str, time_unit: str
720-
) -> pd.Series:
719+
s: pd.Series[int], original_time_unit: str, time_unit: str
720+
) -> pd.Series[int]:
721721
if original_time_unit == "ns":
722722
if time_unit == "ns":
723723
result = s
@@ -752,7 +752,7 @@ def calculate_timestamp_datetime(
752752
return result
753753

754754

755-
def calculate_timestamp_date(s: pd.Series, time_unit: str) -> pd.Series:
755+
def calculate_timestamp_date(s: pd.Series[int], time_unit: str) -> pd.Series[int]:
756756
s = s * 86_400 # number of seconds in a day
757757
if time_unit == "ns":
758758
result = s * 1_000_000_000
@@ -833,7 +833,7 @@ def pivot_table(
833833
return result
834834

835835

836-
def check_column_names_are_unique(columns: pd.Index) -> None:
836+
def check_column_names_are_unique(columns: pd.Index[str]) -> None:
837837
try:
838838
len_unique_columns = len(columns.drop_duplicates())
839839
except Exception: # noqa: BLE001 # pragma: no cover

narwhals/dependencies.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def is_pandas_series(ser: Any) -> TypeIs[pd.Series[Any]]:
136136
)
137137

138138

139-
def is_pandas_index(index: Any) -> TypeIs[pd.Index]:
139+
def is_pandas_index(index: Any) -> TypeIs[pd.Index[Any]]:
140140
"""Check whether `index` is a pandas Index without importing pandas."""
141141
return ((pd := get_pandas()) is not None and isinstance(index, pd.Index)) or any(
142142
(mod := sys.modules.get(module_name, None)) is not None

narwhals/series.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1409,7 +1409,7 @@ def to_numpy(self: Self) -> _1DArray:
14091409
"""
14101410
return self._compliant_series.to_numpy()
14111411

1412-
def to_pandas(self: Self) -> pd.Series:
1412+
def to_pandas(self: Self) -> pd.Series[Any]:
14131413
"""Convert to pandas Series.
14141414
14151415
Returns:

narwhals/translate.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ def get_native_namespace(
792792
| LazyFrame[Any]
793793
| Series[Any]
794794
| pd.DataFrame
795-
| pd.Series
795+
| pd.Series[Any]
796796
| pl.DataFrame
797797
| pl.LazyFrame
798798
| pl.Series

narwhals/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,7 @@ def _is_range_index(obj: Any, native_namespace: Any) -> TypeIs[pd.RangeIndex]:
855855

856856

857857
def _has_default_index(
858-
native_frame_or_series: pd.Series | pd.DataFrame, native_namespace: Any
858+
native_frame_or_series: pd.Series[Any] | pd.DataFrame, native_namespace: Any
859859
) -> bool:
860860
index = native_frame_or_series.index
861861
return (

0 commit comments

Comments
 (0)