Skip to content

Commit

Permalink
intoExpr
Browse files Browse the repository at this point in the history
  • Loading branch information
reswqa committed Sep 18, 2023
1 parent 84537fc commit 525ffc5
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
8 changes: 4 additions & 4 deletions py-polars/polars/expr/binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

if TYPE_CHECKING:
from polars import Expr
from polars.type_aliases import TransferEncoding
from polars.type_aliases import IntoExpr, TransferEncoding


class ExprBinaryNameSpace:
Expand All @@ -18,7 +18,7 @@ class ExprBinaryNameSpace:
def __init__(self, expr: Expr):
self._pyexpr = expr._pyexpr

def contains(self, literal: bytes | Expr) -> Expr:
def contains(self, literal: IntoExpr) -> Expr:
r"""
Check if binaries in Series contain a binary substring.
Expand Down Expand Up @@ -65,7 +65,7 @@ def contains(self, literal: bytes | Expr) -> Expr:
literal = parse_as_expression(literal, str_as_lit=True)
return wrap_expr(self._pyexpr.bin_contains(literal))

def ends_with(self, suffix: bytes | Expr) -> Expr:
def ends_with(self, suffix: IntoExpr) -> Expr:
r"""
Check if string values end with a binary substring.
Expand Down Expand Up @@ -112,7 +112,7 @@ def ends_with(self, suffix: bytes | Expr) -> Expr:
suffix = parse_as_expression(suffix, str_as_lit=True)
return wrap_expr(self._pyexpr.bin_ends_with(suffix))

def starts_with(self, prefix: bytes | Expr) -> Expr:
def starts_with(self, prefix: IntoExpr) -> Expr:
r"""
Check if values start with a binary substring.
Expand Down
3 changes: 2 additions & 1 deletion py-polars/polars/expr/string.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from polars import Expr
from polars.type_aliases import (
Ambiguous,
IntoExpr,
PolarsDataType,
PolarsTemporalType,
TimeUnit,
Expand Down Expand Up @@ -1511,7 +1512,7 @@ def count_matches(self, pattern: str | Expr, *, literal: bool = False) -> Expr:
pattern = parse_as_expression(pattern, str_as_lit=True)
return wrap_expr(self._pyexpr.str_count_matches(pattern, literal))

def split(self, by: str | Expr, *, inclusive: bool = False) -> Expr:
def split(self, by: IntoExpr, *, inclusive: bool = False) -> Expr:
"""
Split the string by a substring.
Expand Down
10 changes: 5 additions & 5 deletions py-polars/polars/series/binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
from polars.series.utils import expr_dispatch

if TYPE_CHECKING:
from polars import Expr, Series
from polars import Series
from polars.polars import PySeries
from polars.type_aliases import TransferEncoding
from polars.type_aliases import IntoExpr, TransferEncoding


@expr_dispatch
Expand All @@ -19,7 +19,7 @@ class BinaryNameSpace:
def __init__(self, series: Series):
self._s: PySeries = series._s

def contains(self, literal: bytes | Expr) -> Series:
def contains(self, literal: IntoExpr) -> Series:
"""
Check if binaries in Series contain a binary substring.
Expand All @@ -35,7 +35,7 @@ def contains(self, literal: bytes | Expr) -> Series:
"""

def ends_with(self, suffix: bytes | Expr) -> Series:
def ends_with(self, suffix: IntoExpr) -> Series:
"""
Check if string values end with a binary substring.
Expand All @@ -46,7 +46,7 @@ def ends_with(self, suffix: bytes | Expr) -> Series:
"""

def starts_with(self, prefix: bytes | Expr) -> Series:
def starts_with(self, prefix: IntoExpr) -> Series:
"""
Check if values start with a binary substring.
Expand Down
3 changes: 2 additions & 1 deletion py-polars/polars/series/string.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from polars.polars import PySeries
from polars.type_aliases import (
Ambiguous,
IntoExpr,
PolarsDataType,
PolarsTemporalType,
TimeUnit,
Expand Down Expand Up @@ -872,7 +873,7 @@ def count_matches(self, pattern: str | Series, *, literal: bool = False) -> Seri
"""

def split(self, by: str | Expr, *, inclusive: bool = False) -> Series:
def split(self, by: IntoExpr, *, inclusive: bool = False) -> Series:
"""
Split the string by a substring.
Expand Down

0 comments on commit 525ffc5

Please sign in to comment.