vars.pyi 5.4 KB

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