Skip to content

Commit

Permalink
refactor[python]: _from_pyexpr as @classmethod (#4681)
Browse files Browse the repository at this point in the history
  • Loading branch information
stinodego committed Sep 2, 2022
1 parent a86ba9b commit e80fccd
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions py-polars/polars/internals/expr/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,18 +131,18 @@ class Expr:
def __init__(self) -> None:
self._pyexpr: PyExpr # pragma: no cover

@classmethod
def _from_pyexpr(cls, pyexpr: PyExpr) -> Expr:
expr = cls.__new__(cls)
expr._pyexpr = pyexpr
return expr

def __str__(self) -> str:
return self._pyexpr.to_str()

def _repr_html_(self) -> str:
return self._pyexpr.to_str()

@staticmethod
def _from_pyexpr(pyexpr: PyExpr) -> Expr:
self = Expr.__new__(Expr)
self._pyexpr = pyexpr
return self

def _to_pyexpr(self, other: Any) -> PyExpr:
return self._to_expr(other)._pyexpr

Expand Down

0 comments on commit e80fccd

Please sign in to comment.