Skip to content

Commit 9d7229a

Browse files
committed
Drop None kwargs so no new Context is created
1 parent b9be645 commit 9d7229a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

pythonwhat/State.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ def to_child(self, append_message="", node_name="", **kwargs):
125125
kwargs["messages"] = [*self.messages, append_message]
126126
kwargs["parent_state"] = self
127127

128+
for kwarg in ["solution_context", "student_context"]:
129+
if kwarg in kwargs and not kwargs[kwarg]:
130+
kwargs.pop(kwarg, None)
131+
128132
def update_kwarg(name, func):
129133
kwargs[name] = func(kwargs[name])
130134

@@ -136,11 +140,11 @@ def update_context(name):
136140
if isinstance(kwargs.get("solution_ast", None), list):
137141
update_kwarg("solution_ast", wrap_in_module)
138142

139-
if kwargs.get("student_ast", None):
143+
if "student_ast" in kwargs:
140144
kwargs["student_code"] = self.student_ast_tokens.get_text(
141145
kwargs["student_ast"]
142146
)
143-
if kwargs.get("solution_ast", None):
147+
if "solution_ast" in kwargs:
144148
kwargs["solution_code"] = self.solution_ast_tokens.get_text(
145149
kwargs["solution_ast"]
146150
)

0 commit comments

Comments
 (0)