vars.pyi 4.9 KB

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