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

feat(python): typing overloads for Series operator methods ge, gt, ... #13167

Merged
merged 4 commits into from
Jan 11, 2024
Merged
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
48 changes: 48 additions & 0 deletions py-polars/polars/series/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,14 +644,38 @@ def __le__(self, other: Any) -> Series | Expr:
return F.lit(self).__le__(other)
return self._comp(other, "lt_eq")

@overload
def le(self, other: Expr) -> Expr: # type: ignore[overload-overlap]
...

@overload
def le(self, other: Any) -> Series:
...

def le(self, other: Any) -> Self | Expr:
"""Method equivalent of operator expression `series <= other`."""
return self.__le__(other)

@overload
def lt(self, other: Expr) -> Expr: # type: ignore[overload-overlap]
...

@overload
def lt(self, other: Any) -> Series:
...

def lt(self, other: Any) -> Self | Expr:
"""Method equivalent of operator expression `series < other`."""
return self.__lt__(other)

@overload
def eq(self, other: Expr) -> Expr: # type: ignore[overload-overlap]
...

@overload
def eq(self, other: Any) -> Series:
...

def eq(self, other: Any) -> Self | Expr:
"""Method equivalent of operator expression `series == other`."""
return self.__eq__(other)
Expand Down Expand Up @@ -703,6 +727,14 @@ def eq_missing(self, other: Any) -> Self | Expr:

"""

@overload
def ne(self, other: Expr) -> Expr: # type: ignore[overload-overlap]
...

@overload
def ne(self, other: Any) -> Series:
...

def ne(self, other: Any) -> Self | Expr:
"""Method equivalent of operator expression `series != other`."""
return self.__ne__(other)
Expand Down Expand Up @@ -754,10 +786,26 @@ def ne_missing(self, other: Any) -> Self | Expr:

"""

@overload
def ge(self, other: Expr) -> Expr: # type: ignore[overload-overlap]
...

@overload
def ge(self, other: Any) -> Series:
...

def ge(self, other: Any) -> Self | Expr:
"""Method equivalent of operator expression `series >= other`."""
return self.__ge__(other)

@overload
def gt(self, other: Expr) -> Expr: # type: ignore[overload-overlap]
...

@overload
def gt(self, other: Any) -> Series:
...

def gt(self, other: Any) -> Self | Expr:
"""Method equivalent of operator expression `series > other`."""
return self.__gt__(other)
Expand Down