From 4711356732bf1b52259c8ff7715cab729527994f Mon Sep 17 00:00:00 2001 From: Benedikt Bartscher Date: Sun, 11 Feb 2024 20:15:39 +0100 Subject: [PATCH 1/3] fix sqlalchemy relationship list type hints --- reflex/utils/types.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/reflex/utils/types.py b/reflex/utils/types.py index abed498eeb9..f2b3257e104 100644 --- a/reflex/utils/types.py +++ b/reflex/utils/types.py @@ -164,7 +164,11 @@ def get_attribute_access_type(cls: GenericType, name: str) -> GenericType | None prop = descriptor.property if not isinstance(prop, Relationship): return None - return prop.mapper.class_ + class_ = prop.mapper.class_ + if prop.uselist: + return list[class_] + else: + return class_ elif isinstance(cls, type) and issubclass(cls, Model): # Check in the annotations directly (for sqlmodel.Relationship) hints = get_type_hints(cls) From 2b8d452cc3e5ef50189a83eb4a57d369f55ea997 Mon Sep 17 00:00:00 2001 From: benedikt-bartscher <31854409+benedikt-bartscher@users.noreply.github.com> Date: Mon, 19 Feb 2024 22:45:56 +0100 Subject: [PATCH 2/3] py3.8 and py3.9 compatibility Co-authored-by: Masen Furer --- reflex/utils/types.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/reflex/utils/types.py b/reflex/utils/types.py index f2b3257e104..de205f5eb6c 100644 --- a/reflex/utils/types.py +++ b/reflex/utils/types.py @@ -166,7 +166,7 @@ def get_attribute_access_type(cls: GenericType, name: str) -> GenericType | None return None class_ = prop.mapper.class_ if prop.uselist: - return list[class_] + return List[class_] else: return class_ elif isinstance(cls, type) and issubclass(cls, Model): From cd98e1c456e11d28d27977d74bde777c9b2dcf68 Mon Sep 17 00:00:00 2001 From: Benedikt Bartscher Date: Tue, 20 Feb 2024 16:26:36 +0100 Subject: [PATCH 3/3] add missing import --- reflex/utils/types.py | 1 + 1 file changed, 1 insertion(+) diff --git a/reflex/utils/types.py b/reflex/utils/types.py index de205f5eb6c..4187d44345f 100644 --- a/reflex/utils/types.py +++ b/reflex/utils/types.py @@ -10,6 +10,7 @@ Any, Callable, Iterable, + List, Literal, Optional, Type,