Skip to content

Commit 96e047c

Browse files
fix: prefer tuple and improve mixin typing
1 parent ad77799 commit 96e047c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

reflex/state.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ def _get_computed_vars(cls) -> list[tuple[str, ComputedVar]]:
487487
"""
488488
return [
489489
(name, v)
490-
for mixin in [*cls._mixins(), cls]
490+
for mixin in (*cls._mixins(), cls)
491491
for name, v in mixin.__dict__.items()
492492
if is_computed_var(v) and name not in cls.inherited_vars
493493
]
@@ -569,14 +569,14 @@ def __init_subclass__(cls, mixin: bool = False, **kwargs):
569569

570570
new_backend_vars = {
571571
name: value if not isinstance(value, Field) else value.default_value()
572-
for mixin_cls in [*cls._mixins(), cls]
572+
for mixin_cls in (*cls._mixins(), cls)
573573
for name, value in list(mixin_cls.__dict__.items())
574574
if types.is_backend_base_variable(name, mixin_cls)
575575
}
576576
# Add annotated backend vars that may not have a default value.
577577
new_backend_vars.update({
578578
name: cls._get_var_default(name, annotation_value)
579-
for mixin_cls in [*cls._mixins(), cls]
579+
for mixin_cls in (*cls._mixins(), cls)
580580
for name, annotation_value in mixin_cls._get_type_hints().items()
581581
if name not in new_backend_vars
582582
and types.is_backend_base_variable(name, mixin_cls)
@@ -764,21 +764,21 @@ def computed_var_func(state: Self):
764764
return getattr(cls, unique_var_name)
765765

766766
@classmethod
767-
def _mixins(cls) -> list[type]:
767+
def _mixins(cls) -> tuple[type[BaseState], ...]:
768768
"""Get the mixin classes of the state.
769769
770770
Returns:
771771
The mixin classes of the state.
772772
"""
773-
return [
773+
return tuple(
774774
mixin
775775
for mixin in cls.__mro__
776776
if (
777777
mixin is not cls
778778
and issubclass(mixin, BaseState)
779779
and mixin._mixin is True
780780
)
781-
]
781+
)
782782

783783
@classmethod
784784
def _handle_local_def(cls):

0 commit comments

Comments
 (0)