i hate rufffff (no i don't)
This commit is contained in:
parent
de1fbdbe5b
commit
1eecd1f9a7
@ -6,7 +6,6 @@ import dataclasses
|
||||
import functools
|
||||
import inspect
|
||||
import sys
|
||||
import traceback
|
||||
from typing import (
|
||||
TYPE_CHECKING,
|
||||
Any,
|
||||
@ -41,21 +40,17 @@ from reflex.vars import (
|
||||
)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from reflex.state import BaseState
|
||||
|
||||
from .function import FunctionVar, ToFunctionOperation
|
||||
from .number import (
|
||||
BooleanVar,
|
||||
NumberVar,
|
||||
ToBooleanVarOperation,
|
||||
ToNumberVarOperation,
|
||||
EqualOperation,
|
||||
GreaterThanOperation,
|
||||
GreaterThanOrEqualOperation,
|
||||
LessThanOperation,
|
||||
LessThanOrEqualOperation,
|
||||
)
|
||||
from .object import ObjectVar, ToObjectOperation
|
||||
from .sequence import ArrayVar, StringVar, ToArrayOperation, ToStringOperation
|
||||
from reflex.state import BaseState
|
||||
|
||||
|
||||
VAR_TYPE = TypeVar("VAR_TYPE")
|
||||
@ -520,8 +515,7 @@ class ImmutableVar(Var, Generic[VAR_TYPE]):
|
||||
return setter
|
||||
|
||||
def __eq__(self, other: Var | Any) -> BooleanVar:
|
||||
"""
|
||||
Check if the current variable is equal to the given variable.
|
||||
"""Check if the current variable is equal to the given variable.
|
||||
|
||||
Args:
|
||||
other (Var | Any): The variable to compare with.
|
||||
@ -534,8 +528,7 @@ class ImmutableVar(Var, Generic[VAR_TYPE]):
|
||||
return EqualOperation(self, other)
|
||||
|
||||
def __ne__(self, other: Var | Any) -> BooleanVar:
|
||||
"""
|
||||
Check if the current object is not equal to the given object.
|
||||
"""Check if the current object is not equal to the given object.
|
||||
|
||||
Parameters:
|
||||
other (Var | Any): The object to compare with.
|
||||
@ -548,8 +541,7 @@ class ImmutableVar(Var, Generic[VAR_TYPE]):
|
||||
return ~EqualOperation(self, other)
|
||||
|
||||
def __gt__(self, other: Var | Any) -> BooleanVar:
|
||||
"""
|
||||
Compare the current instance with another variable and return a BooleanVar representing the result of the greater than operation.
|
||||
"""Compare the current instance with another variable and return a BooleanVar representing the result of the greater than operation.
|
||||
|
||||
Args:
|
||||
other (Var | Any): The variable to compare with.
|
||||
@ -562,8 +554,7 @@ class ImmutableVar(Var, Generic[VAR_TYPE]):
|
||||
return GreaterThanOperation(self, other)
|
||||
|
||||
def __ge__(self, other: Var | Any) -> BooleanVar:
|
||||
"""
|
||||
Check if the value of this variable is greater than or equal to the value of another variable or object.
|
||||
"""Check if the value of this variable is greater than or equal to the value of another variable or object.
|
||||
|
||||
Args:
|
||||
other (Var | Any): The variable or object to compare with.
|
||||
@ -576,8 +567,7 @@ class ImmutableVar(Var, Generic[VAR_TYPE]):
|
||||
return GreaterThanOrEqualOperation(self, other)
|
||||
|
||||
def __lt__(self, other: Var | Any) -> BooleanVar:
|
||||
"""
|
||||
Compare the current instance with another variable using the less than (<) operator.
|
||||
"""Compare the current instance with another variable using the less than (<) operator.
|
||||
|
||||
Args:
|
||||
other: The variable to compare with.
|
||||
@ -590,8 +580,7 @@ class ImmutableVar(Var, Generic[VAR_TYPE]):
|
||||
return LessThanOperation(self, other)
|
||||
|
||||
def __le__(self, other: Var | Any) -> BooleanVar:
|
||||
"""
|
||||
Compare if the current instance is less than or equal to the given value.
|
||||
"""Compare if the current instance is less than or equal to the given value.
|
||||
|
||||
Args:
|
||||
other: The value to compare with.
|
||||
@ -622,7 +611,6 @@ class ImmutableVar(Var, Generic[VAR_TYPE]):
|
||||
Returns:
|
||||
A `BooleanVar` object representing the result of the logical AND operation.
|
||||
"""
|
||||
|
||||
return AndOperation(self, other)
|
||||
|
||||
def __rand__(self, other: Var | Any) -> ImmutableVar:
|
||||
@ -634,7 +622,6 @@ class ImmutableVar(Var, Generic[VAR_TYPE]):
|
||||
Returns:
|
||||
A `BooleanVar` object representing the result of the logical AND operation.
|
||||
"""
|
||||
|
||||
return AndOperation(other, self)
|
||||
|
||||
def __or__(self, other: Var | Any) -> ImmutableVar:
|
||||
@ -646,7 +633,6 @@ class ImmutableVar(Var, Generic[VAR_TYPE]):
|
||||
Returns:
|
||||
A `BooleanVar` object representing the result of the logical OR operation.
|
||||
"""
|
||||
|
||||
return OrOperation(self, other)
|
||||
|
||||
def __ror__(self, other: Var | Any) -> ImmutableVar:
|
||||
@ -658,7 +644,6 @@ class ImmutableVar(Var, Generic[VAR_TYPE]):
|
||||
Returns:
|
||||
A `BooleanVar` object representing the result of the logical OR operation.
|
||||
"""
|
||||
|
||||
return OrOperation(other, self)
|
||||
|
||||
def __invert__(self) -> BooleanVar:
|
||||
@ -687,7 +672,6 @@ class ImmutableVar(Var, Generic[VAR_TYPE]):
|
||||
Returns:
|
||||
The reference to the var.
|
||||
"""
|
||||
|
||||
from .object import ObjectVar
|
||||
|
||||
refs = ImmutableVar(
|
||||
|
@ -7,9 +7,10 @@ import sys
|
||||
from functools import cached_property
|
||||
from typing import Any, Callable, Optional, Tuple, Type, Union
|
||||
|
||||
from .base import ImmutableVar, LiteralVar
|
||||
from reflex.vars import ImmutableVarData, Var, VarData
|
||||
|
||||
from .base import ImmutableVar, LiteralVar
|
||||
|
||||
|
||||
class FunctionVar(ImmutableVar[Callable]):
|
||||
"""Base class for immutable function vars."""
|
||||
|
@ -9,12 +9,12 @@ from functools import cached_property
|
||||
from typing import Any, Union
|
||||
|
||||
from reflex.utils.types import GenericType
|
||||
from reflex.vars import ImmutableVarData, Var, VarData
|
||||
|
||||
from .base import (
|
||||
ImmutableVar,
|
||||
LiteralVar,
|
||||
)
|
||||
from reflex.vars import ImmutableVarData, Var, VarData
|
||||
|
||||
|
||||
class NumberVar(ImmutableVar[Union[int, float]]):
|
||||
|
@ -22,7 +22,9 @@ from typing import (
|
||||
|
||||
from typing_extensions import get_origin
|
||||
|
||||
from reflex.utils import console
|
||||
from reflex.utils.exceptions import VarAttributeError
|
||||
from reflex.utils.types import GenericType, get_attribute_access_type
|
||||
from reflex.vars import ImmutableVarData, Var, VarData
|
||||
|
||||
from .base import (
|
||||
ImmutableVar,
|
||||
@ -31,9 +33,6 @@ from .base import (
|
||||
)
|
||||
from .number import BooleanVar, NumberVar
|
||||
from .sequence import ArrayVar, StringVar
|
||||
from reflex.utils.exceptions import VarAttributeError
|
||||
from reflex.utils.types import GenericType, get_attribute_access_type
|
||||
from reflex.vars import ImmutableVarData, Var, VarData
|
||||
|
||||
OBJECT_TYPE = TypeVar("OBJECT_TYPE")
|
||||
|
||||
@ -371,7 +370,7 @@ class LiteralObjectVar(LiteralVar, ObjectVar[OBJECT_TYPE]):
|
||||
],
|
||||
*[
|
||||
key._get_all_var_data()
|
||||
for key in self._var_value.keys()
|
||||
for key in self._var_value
|
||||
if isinstance(key, Var)
|
||||
],
|
||||
self._var_data,
|
||||
|
@ -27,6 +27,9 @@ from typing_extensions import get_origin
|
||||
|
||||
from reflex import constants
|
||||
from reflex.constants.base import REFLEX_VAR_OPENING_TAG
|
||||
from reflex.utils.types import GenericType
|
||||
from reflex.vars import ImmutableVarData, Var, VarData, _global_vars
|
||||
|
||||
from .base import (
|
||||
ImmutableVar,
|
||||
LiteralVar,
|
||||
@ -39,8 +42,6 @@ from .number import (
|
||||
NotEqualOperation,
|
||||
NumberVar,
|
||||
)
|
||||
from reflex.utils.types import GenericType
|
||||
from reflex.vars import ImmutableVarData, Var, VarData, _global_vars
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .object import ObjectVar
|
||||
@ -72,8 +73,7 @@ class StringVar(ImmutableVar[str]):
|
||||
return ConcatVarOperation(other, self)
|
||||
|
||||
def __mul__(self, other: NumberVar | int) -> StringVar:
|
||||
"""
|
||||
Multiply the sequence by a number or an integer.
|
||||
"""Multiply the sequence by a number or an integer.
|
||||
|
||||
Args:
|
||||
other (NumberVar | int): The number or integer to multiply the sequence by.
|
||||
@ -84,8 +84,7 @@ class StringVar(ImmutableVar[str]):
|
||||
return (self.split() * other).join()
|
||||
|
||||
def __rmul__(self, other: NumberVar | int) -> StringVar:
|
||||
"""
|
||||
Multiply the sequence by a number or an integer.
|
||||
"""Multiply the sequence by a number or an integer.
|
||||
|
||||
Args:
|
||||
other (NumberVar | int): The number or integer to multiply the sequence by.
|
||||
@ -746,7 +745,6 @@ class ArrayVar(ImmutableVar[ARRAY_VAR_TYPE]):
|
||||
Returns:
|
||||
The joined elements.
|
||||
"""
|
||||
|
||||
return ArrayJoinOperation(self, sep)
|
||||
|
||||
def reverse(self) -> ArrayVar[ARRAY_VAR_TYPE]:
|
||||
@ -758,8 +756,7 @@ class ArrayVar(ImmutableVar[ARRAY_VAR_TYPE]):
|
||||
return ArrayReverseOperation(self)
|
||||
|
||||
def __add__(self, other: ArrayVar[ARRAY_VAR_TYPE]) -> ArrayConcatOperation:
|
||||
"""
|
||||
Concatenate two arrays.
|
||||
"""Concatenate two arrays.
|
||||
|
||||
Parameters:
|
||||
other (ArrayVar[ARRAY_VAR_TYPE]): The other array to concatenate.
|
||||
@ -934,8 +931,7 @@ class ArrayVar(ImmutableVar[ARRAY_VAR_TYPE]):
|
||||
return ArrayContainsOperation(self, other)
|
||||
|
||||
def __mul__(self, other: NumberVar | int) -> ArrayVar[ARRAY_VAR_TYPE]:
|
||||
"""
|
||||
Multiply the sequence by a number or integer.
|
||||
"""Multiply the sequence by a number or integer.
|
||||
|
||||
Parameters:
|
||||
other (NumberVar | int): The number or integer to multiply the sequence by.
|
||||
@ -946,8 +942,7 @@ class ArrayVar(ImmutableVar[ARRAY_VAR_TYPE]):
|
||||
return ArrayRepeatOperation(self, other)
|
||||
|
||||
def __rmul__(self, other: NumberVar | int) -> ArrayVar[ARRAY_VAR_TYPE]:
|
||||
"""
|
||||
Multiply the sequence by a number or integer.
|
||||
"""Multiply the sequence by a number or integer.
|
||||
|
||||
Parameters:
|
||||
other (NumberVar | int): The number or integer to multiply the sequence by.
|
||||
|
Loading…
Reference in New Issue
Block a user