Skip to content

Commit 1df827f

Browse files
committed
Apply black formatting
1 parent 100238f commit 1df827f

File tree

2 files changed

+55
-10
lines changed

2 files changed

+55
-10
lines changed

src/browsergym/workarena/tasks/list.py

Lines changed: 50 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -797,14 +797,24 @@ def validate(
797797
current_sep = "^"
798798

799799
if current_kind != self.filter_kind:
800-
return 0, False, "", {"message": f"The kind of filter used is incorrect: {current_query}."}
800+
return (
801+
0,
802+
False,
803+
"",
804+
{"message": f"The kind of filter used is incorrect: {current_query}."},
805+
)
801806

802807
# Extract the query pieces for validation
803808
current_query = current_query.split(current_sep)
804809

805810
# Validate query length is ok
806811
if len(current_query) != self.filter_len:
807-
return 0, False, "", {"message": f"Incorrect number of filter conditions: {current_query}."}
812+
return (
813+
0,
814+
False,
815+
"",
816+
{"message": f"Incorrect number of filter conditions: {current_query}."},
817+
)
808818

809819
# Parse column names, operators, and values
810820
current_columns, current_operators, current_values = [], [], []
@@ -819,18 +829,38 @@ def validate(
819829
current_columns.append(predicate.replace(self.OPERATOR_ISEMPTY, "").strip())
820830
current_operators.append("=")
821831
current_values.append("")
822-
elif any(unsupported_operator in predicate for unsupported_operator in [self.OPERATOR_NOT_EQUALS, self.OPERATOR_STARTSWITH]):
823-
return 0, False, "", {"message": f"Unexpected operator in filter condition: {current_query}."}
832+
elif any(
833+
unsupported_operator in predicate
834+
for unsupported_operator in [self.OPERATOR_NOT_EQUALS, self.OPERATOR_STARTSWITH]
835+
):
836+
return (
837+
0,
838+
False,
839+
"",
840+
{"message": f"Unexpected operator in filter condition: {current_query}."},
841+
)
824842
elif self.OPERATOR_EQUALS in predicate:
825843
col, val = predicate.split(self.OPERATOR_EQUALS, 1)
826844
current_columns.append(col.strip())
827845
current_operators.append("=")
828846
current_values.append(val.strip())
829847
else:
830-
return 0, False, "", {"message": f"Unexpected operator in filter condition: {current_query}."}
848+
return (
849+
0,
850+
False,
851+
"",
852+
{"message": f"Unexpected operator in filter condition: {current_query}."},
853+
)
831854

832855
if set(current_columns) != set(self.filter_columns):
833-
return 0, False, "", {"message": f"Incorrect filter columns: {set(current_columns)}. Expected: {set(self.filter_columns)}."}
856+
return (
857+
0,
858+
False,
859+
"",
860+
{
861+
"message": f"Incorrect filter columns: {set(current_columns)}. Expected: {set(self.filter_columns)}."
862+
},
863+
)
834864

835865
# Validate query values are ok
836866
# This is the tricky part because we need to expand the values to their display values
@@ -884,9 +914,21 @@ def validate(
884914

885915
# Validate the values
886916
if set(current_values) != set(self.filter_values):
887-
return 0, False, "", {"message": f"Incorrect filter values {set(current_values)}. Expected: {set(self.filter_values)}."}
917+
return (
918+
0,
919+
False,
920+
"",
921+
{
922+
"message": f"Incorrect filter values {set(current_values)}. Expected: {set(self.filter_values)}."
923+
},
924+
)
888925

889-
return 1, True, "Nice work, thank you!", {"message": f"Correct filter: {list_info["query"]}."}
926+
return (
927+
1,
928+
True,
929+
"Nice work, thank you!",
930+
{"message": f"Correct filter: {list_info['query']}."},
931+
)
890932

891933

892934
class ExtractListInfoTask(ServiceNowListTask):

tests/test_filter_list_task.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
)
1717
@pytest.mark.slow
1818
def test_validate_filter_list_task(page: Page, query):
19-
fixed_config = {
19+
fixed_config = {
2020
"filter_columns": [
2121
"short_description",
2222
"assigned_to",
@@ -47,7 +47,10 @@ def test_validate_filter_list_task(page: Page, query):
4747
[
4848
("", "There are no filters yet"),
4949
("assignment_groupEMPTYSTRING", "Incorrect number of filter conditions"),
50-
("assigned_toEMPTYSTRING^short_description!=Description", "Unexpected operator in filter condition"),
50+
(
51+
"assigned_toEMPTYSTRING^short_description!=Description",
52+
"Unexpected operator in filter condition",
53+
),
5154
("assigned_toEMPTYSTRING^short_description=Description", "Incorrect filter columns"),
5255
("assigned_toISEMPTY^description=My Description", "Incorrect filter values"),
5356
],

0 commit comments

Comments
 (0)