From 4f50ea4cdfbe1982839ce2a7a550b94eee0010b0 Mon Sep 17 00:00:00 2001 From: Marshall Crumiller Date: Thu, 3 Aug 2023 15:08:16 -0400 Subject: [PATCH] Simplify comparison method redirects --- py-polars/polars/lazyframe/frame.py | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/py-polars/polars/lazyframe/frame.py b/py-polars/polars/lazyframe/frame.py index f0c1d0ab6aec..3da9b22b3e88 100644 --- a/py-polars/polars/lazyframe/frame.py +++ b/py-polars/polars/lazyframe/frame.py @@ -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