From b06c465f71f9fa7623a9b86931dd8700d3321c3b Mon Sep 17 00:00:00 2001 From: Lendemor Date: Wed, 28 May 2025 19:08:07 -0700 Subject: [PATCH 1/2] detect class var that are forward ref --- reflex/utils/types.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/reflex/utils/types.py b/reflex/utils/types.py index 258a6797b0b..db3a462f3f7 100644 --- a/reflex/utils/types.py +++ b/reflex/utils/types.py @@ -263,8 +263,13 @@ def is_classvar(a_type: Any) -> bool: Returns: Whether the type is a ClassVar. """ - return a_type is ClassVar or ( - type(a_type) is _GenericAlias and a_type.__origin__ is ClassVar + return ( + a_type is ClassVar + or (type(a_type) is _GenericAlias and a_type.__origin__ is ClassVar) + or ( + a_type.__class__ == ForwardRef + and a_type.__forward_arg__.startswith("ClassVar") + ) ) From 303eb22be555be6448b261850badd2c5cca635df Mon Sep 17 00:00:00 2001 From: Lendemor Date: Wed, 28 May 2025 19:12:33 -0700 Subject: [PATCH 2/2] cleanup --- reflex/utils/types.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/reflex/utils/types.py b/reflex/utils/types.py index db3a462f3f7..d9b79b17ac8 100644 --- a/reflex/utils/types.py +++ b/reflex/utils/types.py @@ -267,8 +267,7 @@ def is_classvar(a_type: Any) -> bool: a_type is ClassVar or (type(a_type) is _GenericAlias and a_type.__origin__ is ClassVar) or ( - a_type.__class__ == ForwardRef - and a_type.__forward_arg__.startswith("ClassVar") + type(a_type) is ForwardRef and a_type.__forward_arg__.startswith("ClassVar") ) )