vars.pyi 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. """ Generated with stubgen from mypy, then manually edited, do not regen."""
  2. from __future__ import annotations
  3. import datetime
  4. from dataclasses import dataclass
  5. from _typeshed import Incomplete
  6. from reflex import constants as constants
  7. from reflex.base import Base as Base
  8. from reflex.state import State as State
  9. from reflex.state import BaseState as BaseState
  10. from reflex.utils import console as console, format as format, types as types
  11. from reflex.utils.imports import ImportVar, ImportDict, ParsedImportDict
  12. from types import FunctionType
  13. from typing import (
  14. Any,
  15. Callable,
  16. Dict,
  17. Iterable,
  18. List,
  19. Optional,
  20. Set,
  21. Tuple,
  22. Type,
  23. Union,
  24. overload,
  25. _GenericAlias, # type: ignore
  26. )
  27. USED_VARIABLES: Incomplete
  28. def get_unique_variable_name() -> str: ...
  29. def _encode_var(value: Var) -> str: ...
  30. def _decode_var(value: str) -> tuple[VarData, str]: ...
  31. def _extract_var_data(value: Iterable) -> list[VarData | None]: ...
  32. class VarData(Base):
  33. state: str = ""
  34. imports: Union[ImportDict, ParsedImportDict] = {}
  35. hooks: Dict[str, None] = {}
  36. interpolations: List[Tuple[int, int]] = []
  37. @classmethod
  38. def merge(cls, *others: VarData | None) -> VarData | None: ...
  39. class Var:
  40. _var_name: str
  41. _var_type: Type
  42. _var_is_local: bool = False
  43. _var_is_string: bool = False
  44. _var_full_name_needs_state_prefix: bool = False
  45. _var_data: VarData | None = None
  46. @classmethod
  47. def create(
  48. cls, value: Any, _var_is_local: bool = True, _var_is_string: bool | None = None, _var_data: VarData | None = None,
  49. ) -> Optional[Var]: ...
  50. @classmethod
  51. def create_safe(
  52. cls, value: Any, _var_is_local: bool = True, _var_is_string: bool | None = None, _var_data: VarData | None = None,
  53. ) -> Var: ...
  54. @classmethod
  55. def __class_getitem__(cls, type_: Type) -> _GenericAlias: ...
  56. def _replace(self, merge_var_data=None, **kwargs: Any) -> BaseVar: ...
  57. def equals(self, other: Var) -> bool: ...
  58. def to_string(self) -> Var: ...
  59. def __hash__(self) -> int: ...
  60. def __format__(self, format_spec: str) -> str: ...
  61. def __getitem__(self, i: Any) -> Var: ...
  62. def __getattribute__(self, name: str) -> Var: ...
  63. def operation(
  64. self,
  65. op: str = ...,
  66. other: Optional[Var] = ...,
  67. type_: Optional[Type] = ...,
  68. flip: bool = ...,
  69. fn: Optional[str] = ...,
  70. ) -> Var: ...
  71. def compare(self, op: str, other: Var) -> Var: ...
  72. def __invert__(self) -> Var: ...
  73. def __neg__(self) -> Var: ...
  74. def __abs__(self) -> Var: ...
  75. def length(self) -> Var: ...
  76. def __eq__(self, other: Var) -> Var: ...
  77. def __ne__(self, other: Var) -> Var: ...
  78. def __gt__(self, other: Var) -> Var: ...
  79. def __ge__(self, other: Var) -> Var: ...
  80. def __lt__(self, other: Var) -> Var: ...
  81. def __le__(self, other: Var) -> Var: ...
  82. def __add__(self, other: Var) -> Var: ...
  83. def __radd__(self, other: Var) -> Var: ...
  84. def __sub__(self, other: Var) -> Var: ...
  85. def __rsub__(self, other: Var) -> Var: ...
  86. def __mul__(self, other: Var) -> Var: ...
  87. def __rmul__(self, other: Var) -> Var: ...
  88. def __pow__(self, other: Var) -> Var: ...
  89. def __rpow__(self, other: Var) -> Var: ...
  90. def __truediv__(self, other: Var) -> Var: ...
  91. def __rtruediv__(self, other: Var) -> Var: ...
  92. def __floordiv__(self, other: Var) -> Var: ...
  93. def __mod__(self, other: Var) -> Var: ...
  94. def __rmod__(self, other: Var) -> Var: ...
  95. def __and__(self, other: Var) -> Var: ...
  96. def __rand__(self, other: Var) -> Var: ...
  97. def __or__(self, other: Var) -> Var: ...
  98. def __ror__(self, other: Var) -> Var: ...
  99. def __contains__(self, _: Any) -> Var: ...
  100. def contains(self, other: Any) -> Var: ...
  101. def reverse(self) -> Var: ...
  102. def foreach(self, fn: Callable) -> Var: ...
  103. @classmethod
  104. def range(
  105. cls,
  106. v1: Var | int = 0,
  107. v2: Var | int | None = None,
  108. step: Var | int | None = None,
  109. ) -> Var: ...
  110. def to(self, type_: Type) -> Var: ...
  111. def as_ref(self) -> Var: ...
  112. @property
  113. def _var_full_name(self) -> str: ...
  114. def _var_set_state(self, state: Type[BaseState] | str) -> Any: ...
  115. @dataclass(eq=False)
  116. class BaseVar(Var):
  117. _var_name: str
  118. _var_type: Any
  119. _var_is_local: bool = False
  120. _var_is_string: bool = False
  121. _var_full_name_needs_state_prefix: bool = False
  122. _var_data: VarData | None = None
  123. def __hash__(self) -> int: ...
  124. def get_default_value(self) -> Any: ...
  125. def get_setter_name(self, include_state: bool = ...) -> str: ...
  126. def get_setter(self) -> Callable[[BaseState, Any], None]: ...
  127. @dataclass(init=False)
  128. class ComputedVar(Var):
  129. _var_cache: bool
  130. fget: FunctionType
  131. @property
  132. def _cache_attr(self) -> str: ...
  133. def __get__(self, instance, owner): ...
  134. def _deps(self, objclass: Type, obj: Optional[FunctionType] = ...) -> Set[str]: ...
  135. def _replace(self, merge_var_data=None, **kwargs: Any) -> ComputedVar: ...
  136. def mark_dirty(self, instance) -> None: ...
  137. def needs_update(self, instance) -> bool: ...
  138. def _determine_var_type(self) -> Type: ...
  139. @overload
  140. def __init__(
  141. self,
  142. fget: Callable[[BaseState], Any],
  143. **kwargs,
  144. ) -> None: ...
  145. @overload
  146. def __init__(self, func) -> None: ...
  147. @overload
  148. def computed_var(
  149. fget: Callable[[BaseState], Any] | None = None,
  150. initial_value: Any | None = None,
  151. cache: bool = False,
  152. deps: Optional[List[Union[str, Var]]] = None,
  153. auto_deps: bool = True,
  154. interval: Optional[Union[datetime.timedelta, int]] = None,
  155. **kwargs,
  156. ) -> Callable[[Callable[[Any], Any]], ComputedVar]: ...
  157. @overload
  158. def computed_var(fget: Callable[[Any], Any]) -> ComputedVar: ...
  159. @overload
  160. def cached_var(
  161. fget: Callable[[BaseState], Any] | None = None,
  162. initial_value: Any | None = None,
  163. deps: Optional[List[Union[str, Var]]] = None,
  164. auto_deps: bool = True,
  165. interval: Optional[Union[datetime.timedelta, int]] = None,
  166. **kwargs,
  167. ) -> Callable[[Callable[[Any], Any]], ComputedVar]: ...
  168. @overload
  169. def cached_var(fget: Callable[[Any], Any]) -> ComputedVar: ...
  170. class CallableVar(BaseVar):
  171. def __init__(self, fn: Callable[..., BaseVar]): ...
  172. def __call__(self, *args, **kwargs) -> BaseVar: ...
  173. def get_uuid_string_var() -> Var: ...