Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions narwhals/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
from narwhals.series_struct import SeriesStructNamespace
from narwhals.translate import to_native
from narwhals.typing import IntoSeriesT
from narwhals.typing import NonNestedLiteral
from narwhals.typing import SingleIndexSelector
from narwhals.utils import _validate_rolling_arguments
from narwhals.utils import generate_repr
from narwhals.utils import is_compliant_series
Expand All @@ -43,9 +41,11 @@
from narwhals.dtypes import DType
from narwhals.typing import ClosedInterval
from narwhals.typing import FillNullStrategy
from narwhals.typing import NonNestedLiteral
from narwhals.typing import NumericLiteral
from narwhals.typing import RankMethod
from narwhals.typing import RollingInterpolationMethod
from narwhals.typing import SingleIndexSelector
from narwhals.typing import TemporalLiteral
from narwhals.typing import _1DArray
from narwhals.utils import Implementation
Expand Down
8 changes: 1 addition & 7 deletions narwhals/series_cat.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
from __future__ import annotations

from typing import TYPE_CHECKING
from typing import Any
from typing import Generic
from typing import TypeVar

if TYPE_CHECKING:
from narwhals.series import Series

SeriesT = TypeVar("SeriesT", bound="Series[Any]")
from narwhals.typing import SeriesT


class SeriesCatNamespace(Generic[SeriesT]):
Expand Down
7 changes: 2 additions & 5 deletions narwhals/series_dt.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
from __future__ import annotations

from typing import TYPE_CHECKING
from typing import Any
from typing import Generic
from typing import TypeVar

from narwhals.typing import SeriesT

if TYPE_CHECKING:
from narwhals.series import Series
from narwhals.typing import TimeUnit

SeriesT = TypeVar("SeriesT", bound="Series[Any]")


class SeriesDateTimeNamespace(Generic[SeriesT]):
def __init__(self, series: SeriesT) -> None:
Expand Down
9 changes: 1 addition & 8 deletions narwhals/series_list.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
from __future__ import annotations

from typing import TYPE_CHECKING
from typing import Any
from typing import Generic
from typing import TypeVar

if TYPE_CHECKING:
from narwhals.series import Series


SeriesT = TypeVar("SeriesT", bound="Series[Any]")
from narwhals.typing import SeriesT


class SeriesListNamespace(Generic[SeriesT]):
Expand Down
8 changes: 1 addition & 7 deletions narwhals/series_str.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
from __future__ import annotations

from typing import TYPE_CHECKING
from typing import Any
from typing import Generic
from typing import TypeVar

if TYPE_CHECKING:
from narwhals.series import Series

SeriesT = TypeVar("SeriesT", bound="Series[Any]")
from narwhals.typing import SeriesT


class SeriesStringNamespace(Generic[SeriesT]):
Expand Down
8 changes: 1 addition & 7 deletions narwhals/series_struct.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
from __future__ import annotations

from typing import TYPE_CHECKING
from typing import Any
from typing import Generic
from typing import TypeVar

if TYPE_CHECKING:
from narwhals.series import Series

SeriesT = TypeVar("SeriesT", bound="Series[Any]")
from narwhals.typing import SeriesT


class SeriesStructNamespace(Generic[SeriesT]):
Expand Down
122 changes: 60 additions & 62 deletions narwhals/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,67 @@ def filter(self, *args: Any, **kwargs: Any) -> Any: ...
class DataFrameLike(Protocol):
def __dataframe__(self, *args: Any, **kwargs: Any) -> Any: ...

class SupportsNativeNamespace(Protocol):
def __native_namespace__(self) -> ModuleType: ...

class SupportsNativeNamespace(Protocol):
def __native_namespace__(self) -> ModuleType: ...
# ruff: noqa: N802
class DTypes(Protocol):
@property
def Decimal(self) -> type[dtypes.Decimal]: ...
@property
def Int128(self) -> type[dtypes.Int128]: ...
@property
def Int64(self) -> type[dtypes.Int64]: ...
@property
def Int32(self) -> type[dtypes.Int32]: ...
@property
def Int16(self) -> type[dtypes.Int16]: ...
@property
def Int8(self) -> type[dtypes.Int8]: ...
@property
def UInt128(self) -> type[dtypes.UInt128]: ...
@property
def UInt64(self) -> type[dtypes.UInt64]: ...
@property
def UInt32(self) -> type[dtypes.UInt32]: ...
@property
def UInt16(self) -> type[dtypes.UInt16]: ...
@property
def UInt8(self) -> type[dtypes.UInt8]: ...
@property
def Float64(self) -> type[dtypes.Float64]: ...
@property
def Float32(self) -> type[dtypes.Float32]: ...
@property
def String(self) -> type[dtypes.String]: ...
@property
def Boolean(self) -> type[dtypes.Boolean]: ...
@property
def Object(self) -> type[dtypes.Object]: ...
@property
def Categorical(self) -> type[dtypes.Categorical]: ...
@property
def Enum(self) -> type[dtypes.Enum]: ...
@property
def Datetime(self) -> type[dtypes.Datetime]: ...
@property
def Duration(self) -> type[dtypes.Duration]: ...
@property
def Date(self) -> type[dtypes.Date]: ...
@property
def Field(self) -> type[dtypes.Field]: ...
@property
def Struct(self) -> type[dtypes.Struct]: ...
@property
def List(self) -> type[dtypes.List]: ...
@property
def Array(self) -> type[dtypes.Array]: ...
@property
def Unknown(self) -> type[dtypes.Unknown]: ...
@property
def Time(self) -> type[dtypes.Time]: ...
@property
def Binary(self) -> type[dtypes.Binary]: ...


IntoExpr: TypeAlias = Union["Expr", str, "Series[Any]"]
Expand Down Expand Up @@ -331,66 +389,6 @@ def __native_namespace__(self) -> ModuleType: ...
MultiColSelector: TypeAlias = "MultiIndexSelector[_T] | MultiNameSelector[_T]"


# ruff: noqa: N802
class DTypes(Protocol):
@property
def Decimal(self) -> type[dtypes.Decimal]: ...
@property
def Int128(self) -> type[dtypes.Int128]: ...
@property
def Int64(self) -> type[dtypes.Int64]: ...
@property
def Int32(self) -> type[dtypes.Int32]: ...
@property
def Int16(self) -> type[dtypes.Int16]: ...
@property
def Int8(self) -> type[dtypes.Int8]: ...
@property
def UInt128(self) -> type[dtypes.UInt128]: ...
@property
def UInt64(self) -> type[dtypes.UInt64]: ...
@property
def UInt32(self) -> type[dtypes.UInt32]: ...
@property
def UInt16(self) -> type[dtypes.UInt16]: ...
@property
def UInt8(self) -> type[dtypes.UInt8]: ...
@property
def Float64(self) -> type[dtypes.Float64]: ...
@property
def Float32(self) -> type[dtypes.Float32]: ...
@property
def String(self) -> type[dtypes.String]: ...
@property
def Boolean(self) -> type[dtypes.Boolean]: ...
@property
def Object(self) -> type[dtypes.Object]: ...
@property
def Categorical(self) -> type[dtypes.Categorical]: ...
@property
def Enum(self) -> type[dtypes.Enum]: ...
@property
def Datetime(self) -> type[dtypes.Datetime]: ...
@property
def Duration(self) -> type[dtypes.Duration]: ...
@property
def Date(self) -> type[dtypes.Date]: ...
@property
def Field(self) -> type[dtypes.Field]: ...
@property
def Struct(self) -> type[dtypes.Struct]: ...
@property
def List(self) -> type[dtypes.List]: ...
@property
def Array(self) -> type[dtypes.Array]: ...
@property
def Unknown(self) -> type[dtypes.Unknown]: ...
@property
def Time(self) -> type[dtypes.Time]: ...
@property
def Binary(self) -> type[dtypes.Binary]: ...


__all__ = [
"CompliantDataFrame",
"CompliantLazyFrame",
Expand Down
Loading