Skip to content

Commit 101fdb9

Browse files
committed
Add a Var[Callable] test case
1 parent 194711a commit 101fdb9

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

tests/units/reflex_base/utils/pyi_generator/dataset/var_types.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
- Var[T] expansion: Var[str] -> Var[str] | str
55
- Var with Union args: Var[str | int] -> Var[str | int] | str | int
66
- Complex nested types: Var[list[str]], Var[dict[str, Any]], Var[list[dict[str, Any]]]
7+
- Callable prop: Var[Callable[[], bool]] (should NOT expand inner type)
78
- Component with no custom props (just inherited defaults)
89
- Component with only event handlers (no data props)
910
"""
1011

12+
from collections.abc import Callable
1113
from typing import Any
1214

1315
from reflex_base.components.component import Component, field
@@ -43,3 +45,6 @@ class VarTypesComponent(Component):
4345
items: Var[list[str]] = field(doc="A list of string items.")
4446
metadata: Var[dict[str, Any]] = field(doc="Metadata dictionary.")
4547
nested: Var[list[dict[str, Any]]] = field(doc="Nested structures.")
48+
49+
# Callable prop — the inner Callable type should not be expanded.
50+
on_check: Var[Callable[[], bool]] = field(doc="A callable that returns bool.")

tests/units/reflex_base/utils/pyi_generator/golden/var_types.pyi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# ------------------- DO NOT EDIT ----------------------
44
# This file was generated by `reflex/utils/pyi_generator.py`!
55
# ------------------------------------------------------
6-
from collections.abc import Mapping, Sequence
6+
from collections.abc import Callable, Mapping, Sequence
77
from typing import Any
88

99
from reflex_base.components.component import Component
@@ -156,6 +156,7 @@ class VarTypesComponent(Component):
156156
items: Var[list[str]] | list[str] | None = None,
157157
metadata: Var[dict[str, Any]] | dict[str, Any] | None = None,
158158
nested: Var[list[dict[str, Any]]] | list[dict[str, Any]] | None = None,
159+
on_check: Callable[[], bool] | Var[Callable[[], bool]] | None = None,
159160
style: Sequence[Mapping[str, Any]]
160161
| Mapping[str, Any]
161162
| Var[Mapping[str, Any]]
@@ -196,6 +197,7 @@ class VarTypesComponent(Component):
196197
items: A list of string items.
197198
metadata: Metadata dictionary.
198199
nested: Nested structures.
200+
on_check: A callable that returns bool.
199201
style: The style of the component.
200202
key: A unique key for the component.
201203
id: The id for the component.

0 commit comments

Comments
 (0)