Skip to content

Commit b04d0e8

Browse files
committed
Only show warning if instance variables exceeds 0
1 parent 6645444 commit b04d0e8

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

sockpuppet/consumer.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,12 +231,15 @@ def render_page(self, reflex):
231231
instance_variables = [
232232
name
233233
for (name, member) in inspect.getmembers(reflex)
234-
if not name.startswith("__") and name not in PROTECTED_VARIABLES
234+
if not name.startswith("__")
235+
and name not in PROTECTED_VARIABLES
236+
and not callable(getattr(reflex, name))
235237
]
238+
236239
reflex_context = {key: getattr(reflex, key) for key in instance_variables}
237240
reflex_context["stimulus_reflex"] = True
238241

239-
if not reflex.context._attr_data:
242+
if len(instance_variables) > 0:
240243
msg = (
241244
"Setting context through instance variables is deprecated, "
242245
'please use reflex.context.context_variable = "my_data"'

sockpuppet/reflex.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99
"context",
1010
"element",
1111
"params",
12+
"request",
1213
"selectors",
1314
"session",
1415
"url",
16+
"_init_run",
1517
]
1618

1719

@@ -26,6 +28,7 @@ class Context(UserDict):
2628
> context.my_data = 'hello'
2729
> context.my_data # 'hello'
2830
"""
31+
2932
# NOTE for maintainer
3033
# A dictionary that keeps track of whether it's been used as dictionary
3134
# or if values has been set with dot notation. We expect things to be set

0 commit comments

Comments
 (0)