Skip to content

Commit 2ca163d

Browse files
committed
Clarify code
1 parent 2d69853 commit 2ca163d

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

pythonwhat/State.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,16 +178,15 @@ def assert_root(self, fun, extra_msg=""):
178178
)
179179

180180
def assert_execution_root(self, fun, extra_msg=""):
181-
if not (
182-
self.parent_state is None
183-
or self.creator
184-
and self.creator.get("type") == "run"
185-
):
181+
if self.parent_state is not None and not self.assert_creator_type("run"):
186182
raise InstructorError(
187183
"`%s()` should only be called focusing on a full script, following `Ex()` or `run()`. %s"
188184
% (fun, extra_msg)
189185
)
190186

187+
def assert_creator_type(self, type):
188+
return self.creator and self.creator.get("type") == type
189+
191190
def assert_is(self, klasses, fun, prev_fun):
192191
if self.__class__.__name__ not in klasses:
193192
raise InstructorError(

0 commit comments

Comments
 (0)