Skip to content

Commit 8b2c729

Browse files
authored
Add ComputedVar overloads for BASE_TYPE, SQLA_TYPE, and DATACLASS_TYPE (#4777)
Allow typing to find __getattr__ for rx.var that returns an object-like model.
1 parent 3de0415 commit 8b2c729

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

reflex/vars/base.py

+42
Original file line numberDiff line numberDiff line change
@@ -2254,6 +2254,27 @@ def __get__(
22542254
owner: Type,
22552255
) -> ArrayVar[tuple[LIST_INSIDE, ...]]: ...
22562256

2257+
@overload
2258+
def __get__(
2259+
self: ComputedVar[BASE_TYPE],
2260+
instance: None,
2261+
owner: Type,
2262+
) -> ObjectVar[BASE_TYPE]: ...
2263+
2264+
@overload
2265+
def __get__(
2266+
self: ComputedVar[SQLA_TYPE],
2267+
instance: None,
2268+
owner: Type,
2269+
) -> ObjectVar[SQLA_TYPE]: ...
2270+
2271+
if TYPE_CHECKING:
2272+
2273+
@overload
2274+
def __get__(
2275+
self: ComputedVar[DATACLASS_TYPE], instance: None, owner: Any
2276+
) -> ObjectVar[DATACLASS_TYPE]: ...
2277+
22572278
@overload
22582279
def __get__(self, instance: None, owner: Type) -> ComputedVar[RETURN_TYPE]: ...
22592280

@@ -2500,6 +2521,27 @@ def __get__(
25002521
owner: Type,
25012522
) -> ArrayVar[tuple[LIST_INSIDE, ...]]: ...
25022523

2524+
@overload
2525+
def __get__(
2526+
self: AsyncComputedVar[BASE_TYPE],
2527+
instance: None,
2528+
owner: Type,
2529+
) -> ObjectVar[BASE_TYPE]: ...
2530+
2531+
@overload
2532+
def __get__(
2533+
self: AsyncComputedVar[SQLA_TYPE],
2534+
instance: None,
2535+
owner: Type,
2536+
) -> ObjectVar[SQLA_TYPE]: ...
2537+
2538+
if TYPE_CHECKING:
2539+
2540+
@overload
2541+
def __get__(
2542+
self: AsyncComputedVar[DATACLASS_TYPE], instance: None, owner: Any
2543+
) -> ObjectVar[DATACLASS_TYPE]: ...
2544+
25032545
@overload
25042546
def __get__(self, instance: None, owner: Type) -> AsyncComputedVar[RETURN_TYPE]: ...
25052547

0 commit comments

Comments
 (0)