diff --git a/reflex/components/core/match.py b/reflex/components/core/match.py index a053b9abe..8b577a261 100644 --- a/reflex/components/core/match.py +++ b/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. diff --git a/reflex/event.py b/reflex/event.py index dee33bced..bfab52b71 100644 --- a/reflex/event.py +++ b/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: diff --git a/reflex/vars/number.py b/reflex/vars/number.py index 1e85a1c74..4e7beb390 100644 --- a/reflex/vars/number.py +++ b/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[Unpack[tuple[Var[Any], ...]], Var[VAR_TYPE]] -TUPLE_ENDS_IN_VAR = tuple[*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(