Skip to content

Commit 5047bf4

Browse files
committed
Remove v1
1 parent ddbcf92 commit 5047bf4

32 files changed

+33
-2716
lines changed

pythonwhat/checks/check_object.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
isDefinedCollInProcess,
1313
)
1414
from pythonwhat.checks.check_funcs import part_to_child
15-
from pythonwhat.utils import v2_only
1615
import pandas as pd
1716
import ast
1817

@@ -155,11 +154,8 @@ def __init__(self, n):
155154
and seeing if the result of running this expression in both student and solution process match.
156155
157156
"""
158-
159-
# Only do the assertion if PYTHONWHAT_V2_ONLY is set to '1'
160-
if v2_only():
161-
extra_msg = "If you want to check the value of an object in e.g. a for loop, use `has_equal_value(name = 'my_obj')` instead."
162-
state.assert_execution_root("check_object", extra_msg=extra_msg)
157+
extra_msg = "If you want to check the value of an object in e.g. a for loop, use `has_equal_value(name = 'my_obj')` instead."
158+
state.assert_execution_root("check_object", extra_msg=extra_msg)
163159

164160
if missing_msg is None:
165161
missing_msg = "Did you define the {{typestr}} `{{index}}` without errors?"

pythonwhat/checks/has_funcs.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,8 @@ def has_equal_ast(state, incorrect_msg=None, code=None, exact=True, append=None)
152152
Ex().check_function('numpy.mean').check_args('a').has_equal_ast()
153153
154154
"""
155-
if utils.v2_only():
156-
state.assert_is_not(["object_assignments"], "has_equal_ast", ["check_object"])
157-
state.assert_is_not(["function_calls"], "has_equal_ast", ["check_function"])
155+
state.assert_is_not(["object_assignments"], "has_equal_ast", ["check_object"])
156+
state.assert_is_not(["function_calls"], "has_equal_ast", ["check_function"])
158157

159158
if code and incorrect_msg is None:
160159
raise InstructorError.from_message(

pythonwhat/probe.py

-254
This file was deleted.

pythonwhat/sct_syntax.py

-39
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,10 @@
11
from protowhat.sct_syntax import EagerChain, ExGen, LazyChainStart, state_dec_gen, LazyChain
22
from pythonwhat.checks.check_wrappers import scts
33
from pythonwhat.State import State
4-
from pythonwhat.probe import Node, Probe, TEST_NAMES
5-
from pythonwhat.utils import include_v1
6-
from pythonwhat import test_funcs
7-
from functools import wraps
84

95
# TODO: could define scts for check_wrappers at the module level
106
sct_dict = scts.copy()
117

12-
13-
def multi_dec(f):
14-
"""Decorator for multi to remove nodes for original test functions from root node"""
15-
16-
@wraps(f)
17-
def wrapper(*args, **kwargs):
18-
args = (
19-
args[0] if len(args) == 1 and isinstance(args[0], (list, tuple)) else args
20-
)
21-
for arg in args:
22-
if isinstance(arg, Node) and arg.parent.name is "root":
23-
arg.parent.remove_child(arg)
24-
arg.update_child_calls()
25-
return f(*args, **kwargs)
26-
27-
return wrapper
28-
29-
308
state_dec = state_dec_gen(sct_dict)
319

3210
# todo: __all__?
@@ -49,22 +27,5 @@ def get_chains():
4927
}
5028

5129

52-
if include_v1():
53-
# Prepare SCTs that may be chained attributes ----------------------
54-
# decorate functions that may try to run test_* function nodes as subtests
55-
# so they remove those nodes from the tree
56-
for k in ["multi", "with_context"]:
57-
sct_dict[k] = multi_dec(sct_dict[k])
58-
59-
# allow test_* functions as chained attributes
60-
for k in TEST_NAMES:
61-
sct_dict[k] = Probe(tree=None, f=getattr(test_funcs, k), eval_on_call=True)
62-
63-
# original logical test_* functions behave like multi
64-
# this is necessary to allow them to take check_* funcs as args
65-
# since probe behavior will try to call all SCTs passed (assuming they're also probes)
66-
for k in ["test_or", "test_correct"]:
67-
sct_dict[k] = multi_dec(getattr(test_funcs, k))
68-
6930
# Prepare check_funcs to be used alone (e.g. test = check_with().check_body())
7031
v2_check_functions = {k: state_dec(v) for k, v in scts.items()}

pythonwhat/test_exercise.py

+1-16
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from pythonwhat.utils import check_str, check_process
55
from protowhat.Reporter import Reporter
66
from protowhat.failure import Failure, InstructorError
7-
from pythonwhat.utils import include_v1
87

98

109
def test_exercise(
@@ -51,16 +50,11 @@ def test_exercise(
5150
)
5251

5352
State.root_state = state
54-
tree, sct_cntxt = prep_context()
53+
sct_cntxt = prep_context()
5554

5655
# Actually execute SCTs
5756
exec(sct, sct_cntxt)
5857

59-
# Run remaining nodes on tree (v1 only)
60-
if tree:
61-
for test in tree.crnt_node:
62-
test(state)
63-
6458
except Failure as e:
6559
if isinstance(e, InstructorError):
6660
# TODO: decide based on context
@@ -88,7 +82,6 @@ def allow_errors():
8882
def prep_context():
8983
cntxt = {"success_msg": success_msg}
9084
from pythonwhat.sct_syntax import v2_check_functions
91-
from pythonwhat.probe import build_probe_context
9285

9386
imports = [
9487
"from inspect import Parameter as param",
@@ -98,17 +91,9 @@ def prep_context():
9891
]
9992
[exec(line, None, cntxt) for line in imports]
10093

101-
# only if PYTHONWHAT_V2_ONLY is not set, support v1
102-
if include_v1():
103-
tree, probe_cntxt = build_probe_context()
104-
cntxt.update(probe_cntxt)
105-
else:
106-
tree = None
107-
10894
cntxt.update(v2_check_functions)
10995
# TODO: ChainStart instances cause errors when dill tries to pass manual converter functions
11096
# cntxt.update(get_chains())
111-
return tree, cntxt
11297

11398

11499
def setup_state(stu_code="", sol_code="", pec="", **kwargs):

0 commit comments

Comments
 (0)