Skip to content

Commit

Permalink
docs: fix is_between signature type hint
Browse files Browse the repository at this point in the history
  • Loading branch information
FBruzzesi committed Jan 8, 2025
1 parent 1f0c718 commit 20ef892
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 12 deletions.
7 changes: 6 additions & 1 deletion narwhals/_arrow/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,12 @@ def is_null(self: Self) -> Self:
def is_nan(self: Self) -> Self:
return reuse_series_implementation(self, "is_nan")

def is_between(self: Self, lower_bound: Any, upper_bound: Any, closed: str) -> Self:
def is_between(
self: Self,
lower_bound: Any,
upper_bound: Any,
closed: Literal["left", "right", "none", "both"],
) -> Self:
return reuse_series_implementation(
self,
"is_between",
Expand Down
5 changes: 4 additions & 1 deletion narwhals/_arrow/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,10 @@ def all(self: Self, *, _return_py_scalar: bool = True) -> bool:
)

def is_between(
self, lower_bound: Any, upper_bound: Any, closed: str = "both"
self,
lower_bound: Any,
upper_bound: Any,
closed: Literal["left", "right", "none", "both"],
) -> Self:
import pyarrow.compute as pc

Expand Down
7 changes: 3 additions & 4 deletions narwhals/_dask/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,18 +413,17 @@ def is_between(
self,
lower_bound: Self | Any,
upper_bound: Self | Any,
closed: str = "both",
closed: Literal["left", "right", "none", "both"] = "both",
) -> Self:
if closed == "none":
closed = "neither"
closed_ = "neither" if closed == "none" else closed
return self._from_call(
lambda _input, lower_bound, upper_bound, closed: _input.between(
lower_bound, upper_bound, closed
),
"is_between",
lower_bound=lower_bound,
upper_bound=upper_bound,
closed=closed,
closed=closed_,
returns_scalar=self._returns_scalar,
)

Expand Down
5 changes: 4 additions & 1 deletion narwhals/_pandas_like/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,10 @@ def clip(self, lower_bound: Any, upper_bound: Any) -> Self:
)

def is_between(
self, lower_bound: Any, upper_bound: Any, closed: str = "both"
self,
lower_bound: Any,
upper_bound: Any,
closed: Literal["left", "right", "none", "both"],
) -> Self:
return reuse_series_implementation(
self,
Expand Down
5 changes: 4 additions & 1 deletion narwhals/_pandas_like/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,10 @@ def to_list(self) -> Any:
return self._native_series.to_list()

def is_between(
self, lower_bound: Any, upper_bound: Any, closed: str = "both"
self,
lower_bound: Any,
upper_bound: Any,
closed: Literal["left", "right", "none", "both"],
) -> PandasLikeSeries:
ser = self._native_series
_, lower_bound = broadcast_align_and_extract_native(self, lower_bound)
Expand Down
3 changes: 2 additions & 1 deletion narwhals/_spark_like/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from typing import TYPE_CHECKING
from typing import Any
from typing import Callable
from typing import Literal
from typing import Sequence

from narwhals._expression_parsing import infer_new_root_output_names
Expand Down Expand Up @@ -276,7 +277,7 @@ def is_between(
self,
lower_bound: Any,
upper_bound: Any,
closed: str,
closed: Literal["left", "right", "none", "both"],
) -> Self:
def _is_between(_input: Column, lower_bound: Any, upper_bound: Any) -> Column:
if closed == "both":
Expand Down
4 changes: 2 additions & 2 deletions narwhals/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -1792,10 +1792,10 @@ def sort(self, *, descending: bool = False, nulls_last: bool = False) -> Self:

# --- transform ---
def is_between(
self,
self: Self,
lower_bound: Any | IntoExpr,
upper_bound: Any | IntoExpr,
closed: str = "both",
closed: Literal["left", "right", "none", "both"] = "both",
) -> Self:
"""Check if this expression is between the given lower and upper bounds.
Expand Down
5 changes: 4 additions & 1 deletion narwhals/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -2605,7 +2605,10 @@ def fill_null(
)

def is_between(
self, lower_bound: Any | Self, upper_bound: Any | Self, closed: str = "both"
self: Self,
lower_bound: Any | Self,
upper_bound: Any | Self,
closed: Literal["left", "right", "none", "both"] = "both",
) -> Self:
"""Get a boolean mask of the values that are between the given lower/upper bounds.
Expand Down

0 comments on commit 20ef892

Please sign in to comment.