diff --git a/reflex/components/component.py b/reflex/components/component.py index f73fa10d4..63d3f1622 100644 --- a/reflex/components/component.py +++ b/reflex/components/component.py @@ -194,7 +194,7 @@ class Component(BaseComponent, ABC): ValueError: If a prop value is invalid. """ # Set the id and children initially. - children = kwargs.get("children", []) + kwargs.get("children", []) # kwargs = { # **{ # prop: Var.create(None) if field.is_required() and types._issubclass(field.annotation, Var) else field.default @@ -551,7 +551,7 @@ class Component(BaseComponent, ABC): name for name, field in cls.get_fields().items() if name in cls.get_props() - and types._issubclass(field.outer_type_, Component) + and types._issubclass(field.annotation, Component) } @classmethod diff --git a/reflex/config.py b/reflex/config.py index c3149adb2..08113d127 100644 --- a/reflex/config.py +++ b/reflex/config.py @@ -6,14 +6,14 @@ import importlib import os import sys import urllib.parse -from typing import Any, Dict, List, Optional, Set +from typing import Any, Dict, List, Optional, Set, get_args import pydantic from reflex_cli.constants.hosting import Hosting from reflex import constants from reflex.base import Base -from reflex.utils import console +from reflex.utils import console, types class DBConfig(Base): @@ -264,14 +264,16 @@ class Config(Base): # Convert the env var to the expected type. try: - if issubclass(field.type_, bool): + if types._issubclass(field.annotation, bool): # special handling for bool values env_var = env_var.lower() in ["true", "1", "yes"] + elif types.is_generic_alias(field.annotation): + env_var = get_args(field.annotation)[0](env_var) else: - env_var = field.type_(env_var) + env_var = field.annotation(env_var) except ValueError: console.error( - f"Could not convert {key.upper()}={env_var} to type {field.type_}" + f"Could not convert {key.upper()}={env_var} to type {field.annotation}" ) raise