Browse Source

fix version python 3.10

Khaleel Al-Adhami 4 months ago
parent
commit
0798cb8f60
3 changed files with 18 additions and 11 deletions
  1. 6 2
      reflex/components/core/match.py
  2. 6 5
      reflex/event.py
  3. 6 4
      reflex/vars/number.py

+ 6 - 2
reflex/components/core/match.py

@@ -3,6 +3,8 @@
 import textwrap
 from typing import Any, List, cast
 
+from typing_extensions import Unpack
+
 from reflex.components.base import Fragment
 from reflex.components.component import BaseComponent, Component, MemoizationLeaf
 from reflex.utils import types
@@ -10,7 +12,7 @@ from reflex.utils.exceptions import MatchTypeError
 from reflex.vars.base import VAR_TYPE, Var
 from reflex.vars.number import MatchOperation
 
-CASE_TYPE = tuple[*tuple[Any, ...], Var[VAR_TYPE] | VAR_TYPE]
+CASE_TYPE = tuple[Unpack[tuple[Any, ...]], Var[VAR_TYPE] | VAR_TYPE]
 
 
 class Match(MemoizationLeaf):
@@ -29,7 +31,9 @@ class Match(MemoizationLeaf):
     def create(
         cls,
         cond: Any,
-        *cases: *tuple[*tuple[CASE_TYPE[VAR_TYPE], ...], Var[VAR_TYPE] | VAR_TYPE],
+        *cases: Unpack[
+            tuple[Unpack[tuple[CASE_TYPE[VAR_TYPE], ...]], Var[VAR_TYPE] | VAR_TYPE]
+        ],
     ) -> Var[VAR_TYPE]:
         """Create a Match Component.
 

+ 6 - 5
reflex/event.py

@@ -33,6 +33,7 @@ from typing_extensions import (
     TypedDict,
     TypeVar,
     TypeVarTuple,
+    Unpack,
     deprecated,
     get_args,
     get_origin,
@@ -627,10 +628,10 @@ EVENT_U = TypeVar("EVENT_U")
 Ts = TypeVarTuple("Ts")
 
 
-class IdentityEventReturn(Generic[*Ts], Protocol):
+class IdentityEventReturn(Generic[Unpack[Ts]], Protocol):
     """Protocol for an identity event return."""
 
-    def __call__(self, *values: *Ts) -> tuple[*Ts]:
+    def __call__(self, *values: Unpack[Ts]) -> tuple[Unpack[Ts]]:
         """Return the input values.
 
         Args:
@@ -656,13 +657,13 @@ def passthrough_event_spec(
 
 @overload
 def passthrough_event_spec(
-    *event_types: *tuple[Type[EVENT_T]],
-) -> IdentityEventReturn[*tuple[Var[EVENT_T], ...]]: ...
+    *event_types: Unpack[tuple[Type[EVENT_T]]],
+) -> IdentityEventReturn[Unpack[tuple[Var[EVENT_T], ...]]]: ...
 
 
 def passthrough_event_spec(  # pyright: ignore[reportInconsistentOverload]
     *event_types: Type[EVENT_T],
-) -> IdentityEventReturn[*tuple[Var[EVENT_T], ...]]:
+) -> IdentityEventReturn[Unpack[tuple[Var[EVENT_T], ...]]]:
     """A helper function that returns the input event as output.
 
     Args:

+ 6 - 4
reflex/vars/number.py

@@ -19,6 +19,8 @@ from typing import (
     overload,
 )
 
+from typing_extensions import Unpack
+
 from reflex.constants.base import Dirs
 from reflex.utils.exceptions import PrimitiveUnserializableToJSON, VarTypeError
 from reflex.utils.imports import ImportDict, ImportVar
@@ -1069,11 +1071,11 @@ def ternary_operation(
     return value
 
 
-X = tuple[*tuple[Var, ...], str]
-
-TUPLE_ENDS_IN_VAR = tuple[*tuple[Var[Any], ...], Var[VAR_TYPE]]
+TUPLE_ENDS_IN_VAR = tuple[Unpack[tuple[Var[Any], ...]], Var[VAR_TYPE]]
 
-TUPLE_ENDS_IN_VAR_RELAXED = tuple[*tuple[Var[Any] | Any, ...], Var[VAR_TYPE] | VAR_TYPE]
+TUPLE_ENDS_IN_VAR_RELAXED = tuple[
+    Unpack[tuple[Var[Any] | Any, ...]], Var[VAR_TYPE] | VAR_TYPE
+]
 
 
 @dataclasses.dataclass(