Browse Source

convert literal type to its variants (#4062)

Khaleel Al-Adhami 7 months ago
parent
commit
8528f67a4a
1 changed files with 4 additions and 0 deletions
  1. 4 0
      reflex/vars/base.py

+ 4 - 0
reflex/vars/base.py

@@ -547,6 +547,10 @@ class Var(Generic[VAR_TYPE]):
 
             return self
 
+        if fixed_type is Literal:
+            args = get_args(var_type)
+            fixed_type = unionize(*(type(arg) for arg in args))
+
         if not inspect.isclass(fixed_type):
             raise TypeError(f"Unsupported type {var_type} for guess_type.")