Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(python): Change method op type hints to match dunder op type hints #18448

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
38 changes: 19 additions & 19 deletions py-polars/polars/expr/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -4965,7 +4965,7 @@ def limit(self, n: int | Expr = 10) -> Expr:
"""
return self.head(n)

def and_(self, *others: Any) -> Expr:
def and_(self, *others: IntoExprColumn | int | bool) -> Expr:
"""
Method equivalent of bitwise "and" operator `expr & other & ...`.

Expand Down Expand Up @@ -5006,9 +5006,9 @@ def and_(self, *others: Any) -> Expr:
│ false │
└───────┘
"""
return reduce(operator.and_, (self, *others))
return reduce(operator.and_, (self, *others)) # type: ignore[return-value]

def or_(self, *others: Any) -> Expr:
def or_(self, *others: IntoExprColumn | int | bool) -> Expr:
"""
Method equivalent of bitwise "or" operator `expr | other | ...`.

Expand Down Expand Up @@ -5048,9 +5048,9 @@ def or_(self, *others: Any) -> Expr:
│ false │
└───────┘
"""
return reduce(operator.or_, (self,) + others)
return reduce(operator.or_, (self,) + others) # type: ignore[return-value]

def eq(self, other: Any) -> Expr:
def eq(self, other: IntoExpr) -> Expr:
"""
Method equivalent of equality operator `expr == other`.

Expand Down Expand Up @@ -5084,7 +5084,7 @@ def eq(self, other: Any) -> Expr:
"""
return self.__eq__(other)

def eq_missing(self, other: Any) -> Expr:
def eq_missing(self, other: IntoExpr) -> Expr:
"""
Method equivalent of equality operator `expr == other` where `None == None`.

Expand Down Expand Up @@ -5124,7 +5124,7 @@ def eq_missing(self, other: Any) -> Expr:
other = parse_into_expression(other, str_as_lit=True)
return self._from_pyexpr(self._pyexpr.eq_missing(other))

def ge(self, other: Any) -> Expr:
def ge(self, other: IntoExpr) -> Expr:
"""
Method equivalent of "greater than or equal" operator `expr >= other`.

Expand Down Expand Up @@ -5158,7 +5158,7 @@ def ge(self, other: Any) -> Expr:
"""
return self.__ge__(other)

def gt(self, other: Any) -> Expr:
def gt(self, other: IntoExpr) -> Expr:
"""
Method equivalent of "greater than" operator `expr > other`.

Expand Down Expand Up @@ -5192,7 +5192,7 @@ def gt(self, other: Any) -> Expr:
"""
return self.__gt__(other)

def le(self, other: Any) -> Expr:
def le(self, other: IntoExpr) -> Expr:
"""
Method equivalent of "less than or equal" operator `expr <= other`.

Expand Down Expand Up @@ -5226,7 +5226,7 @@ def le(self, other: Any) -> Expr:
"""
return self.__le__(other)

def lt(self, other: Any) -> Expr:
def lt(self, other: IntoExpr) -> Expr:
"""
Method equivalent of "less than" operator `expr < other`.

Expand Down Expand Up @@ -5260,7 +5260,7 @@ def lt(self, other: Any) -> Expr:
"""
return self.__lt__(other)

def ne(self, other: Any) -> Expr:
def ne(self, other: IntoExpr) -> Expr:
"""
Method equivalent of inequality operator `expr != other`.

Expand Down Expand Up @@ -5294,7 +5294,7 @@ def ne(self, other: Any) -> Expr:
"""
return self.__ne__(other)

def ne_missing(self, other: Any) -> Expr:
def ne_missing(self, other: IntoExpr) -> Expr:
"""
Method equivalent of equality operator `expr != other` where `None == None`.

Expand Down Expand Up @@ -5334,7 +5334,7 @@ def ne_missing(self, other: Any) -> Expr:
other = parse_into_expression(other, str_as_lit=True)
return self._from_pyexpr(self._pyexpr.neq_missing(other))

def add(self, other: Any) -> Expr:
def add(self, other: IntoExpr) -> Expr:
"""
Method equivalent of addition operator `expr + other`.

Expand Down Expand Up @@ -5380,7 +5380,7 @@ def add(self, other: Any) -> Expr:
"""
return self.__add__(other)

def floordiv(self, other: Any) -> Expr:
def floordiv(self, other: IntoExpr) -> Expr:
"""
Method equivalent of integer division operator `expr // other`.

Expand Down Expand Up @@ -5467,7 +5467,7 @@ def floordiv(self, other: Any) -> Expr:
"""
return self.__floordiv__(other)

def mod(self, other: Any) -> Expr:
def mod(self, other: IntoExpr) -> Expr:
"""
Method equivalent of modulus operator `expr % other`.

Expand Down Expand Up @@ -5495,7 +5495,7 @@ def mod(self, other: Any) -> Expr:
"""
return self.__mod__(other)

def mul(self, other: Any) -> Expr:
def mul(self, other: IntoExpr) -> Expr:
"""
Method equivalent of multiplication operator `expr * other`.

Expand Down Expand Up @@ -5526,7 +5526,7 @@ def mul(self, other: Any) -> Expr:
"""
return self.__mul__(other)

def sub(self, other: Any) -> Expr:
def sub(self, other: IntoExpr) -> Expr:
"""
Method equivalent of subtraction operator `expr - other`.

Expand Down Expand Up @@ -5579,7 +5579,7 @@ def neg(self) -> Expr:
"""
return self.__neg__()

def truediv(self, other: Any) -> Expr:
def truediv(self, other: IntoExpr) -> Expr:
"""
Method equivalent of float division operator `expr / other`.

Expand Down Expand Up @@ -5676,7 +5676,7 @@ def pow(self, exponent: IntoExprColumn | int | float) -> Expr:
"""
return self.__pow__(exponent)

def xor(self, other: Any) -> Expr:
def xor(self, other: IntoExprColumn | int | bool) -> Expr:
"""
Method equivalent of bitwise exclusive-or operator `expr ^ other`.

Expand Down