convert literal type to its variants (#4062)

This commit is contained in:
Khaleel Al-Adhami 2024-10-04 13:56:25 -07:00 committed by Masen Furer
parent 9dafe5f813
commit 8528f67a4a
No known key found for this signature in database
GPG Key ID: B0008AD22B3B3A95

View File

@ -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.")