Skip to content

Commit

Permalink
Simplify comparison method redirects
Browse files Browse the repository at this point in the history
  • Loading branch information
mcrumiller committed Aug 3, 2023
1 parent 8e59194 commit 4f50ea4
Showing 1 changed file with 7 additions and 18 deletions.
25 changes: 7 additions & 18 deletions py-polars/polars/lazyframe/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,29 +660,18 @@ def __bool__(self) -> NoReturn:
"cannot be used in boolean context with and/or/not operators. "
)

def _comparison_error(self) -> NoReturn:
def _comparison_error(self, other: Any) -> NoReturn:
raise TypeError(
"Cannot compare ambiguous LazyFrame structures; call .collect() "
"to materialize to DataFrame before comparison."
)

def __eq__(self, other: Any) -> NoReturn:
self._comparison_error()

def __ne__(self, other: Any) -> NoReturn:
self._comparison_error()

def __gt__(self, other: Any) -> NoReturn:
self._comparison_error()

def __lt__(self, other: Any) -> NoReturn:
self._comparison_error()

def __ge__(self, other: Any) -> NoReturn:
self._comparison_error()

def __le__(self, other: Any) -> NoReturn:
self._comparison_error()
__eq__ = _comparison_error
__ne__ = _comparison_error
__gt__ = _comparison_error
__lt__ = _comparison_error
__ge__ = _comparison_error
__le__ = _comparison_error

def __contains__(self, key: str) -> bool:
return key in self.columns
Expand Down

0 comments on commit 4f50ea4

Please sign in to comment.