Skip to content

Commit 5246a6f

Browse files
committed
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 9c9491a commit 5246a6f

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

reflex/vars/base.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2238,6 +2238,27 @@ def __get__(
22382238
owner: Type,
22392239
) -> ArrayVar[tuple[LIST_INSIDE, ...]]: ...
22402240

2241+
@overload
2242+
def __get__(
2243+
self: ComputedVar[BASE_TYPE],
2244+
instance: None,
2245+
owner: Type,
2246+
) -> ObjectVar[BASE_TYPE]: ...
2247+
2248+
@overload
2249+
def __get__(
2250+
self: ComputedVar[SQLA_TYPE],
2251+
instance: None,
2252+
owner: Type,
2253+
) -> ObjectVar[SQLA_TYPE]: ...
2254+
2255+
if TYPE_CHECKING:
2256+
2257+
@overload
2258+
def __get__(
2259+
self: ComputedVar[DATACLASS_TYPE], instance: None, owner: Any
2260+
) -> ObjectVar[DATACLASS_TYPE]: ...
2261+
22412262
@overload
22422263
def __get__(self, instance: None, owner: Type) -> ComputedVar[RETURN_TYPE]: ...
22432264

@@ -2484,6 +2505,27 @@ def __get__(
24842505
owner: Type,
24852506
) -> ArrayVar[tuple[LIST_INSIDE, ...]]: ...
24862507

2508+
@overload
2509+
def __get__(
2510+
self: AsyncComputedVar[BASE_TYPE],
2511+
instance: None,
2512+
owner: Type,
2513+
) -> ObjectVar[BASE_TYPE]: ...
2514+
2515+
@overload
2516+
def __get__(
2517+
self: AsyncComputedVar[SQLA_TYPE],
2518+
instance: None,
2519+
owner: Type,
2520+
) -> ObjectVar[SQLA_TYPE]: ...
2521+
2522+
if TYPE_CHECKING:
2523+
2524+
@overload
2525+
def __get__(
2526+
self: AsyncComputedVar[DATACLASS_TYPE], instance: None, owner: Any
2527+
) -> ObjectVar[DATACLASS_TYPE]: ...
2528+
24872529
@overload
24882530
def __get__(self, instance: None, owner: Type) -> AsyncComputedVar[RETURN_TYPE]: ...
24892531

0 commit comments

Comments
 (0)