Skip to content

Commit 55035f7

Browse files
committed
Clean up State helpers
- use new helper from protowhat and remove deprecated one - improve name of pythonwhat helper
1 parent 8014b80 commit 55035f7

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

pythonwhat/State.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -181,22 +181,14 @@ def has_different_processes(self):
181181
# play it safe (most common)
182182
return True
183183

184-
# todo: remove (deprecated)
185-
def assert_root(self, fun, extra_msg=""):
186-
if self.parent_state is not None:
187-
raise InstructorError(
188-
"`%s()` should only be called from the root state, `Ex()`. %s"
189-
% (fun, extra_msg)
190-
)
191-
192184
def assert_execution_root(self, fun, extra_msg=""):
193-
if self.parent_state is not None and not self.assert_creator_type("run"):
185+
if not (self.is_root or self.is_creator_type("run")):
194186
raise InstructorError(
195187
"`%s()` should only be called focusing on a full script, following `Ex()` or `run()`. %s"
196188
% (fun, extra_msg)
197189
)
198190

199-
def assert_creator_type(self, type):
191+
def is_creator_type(self, type):
200192
return self.creator and self.creator.get("type") == type
201193

202194
def assert_is(self, klasses, fun, prev_fun):

0 commit comments

Comments
 (0)