Skip to content

Commit

Permalink
Apply automated ruff unsafe fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
wjrm500 committed Dec 13, 2024
1 parent 4eeb3c4 commit 6e361cb
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 11 deletions.
16 changes: 12 additions & 4 deletions app/all_questions/metadata_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ def update_wording_for_multi_input_fields(text: list) -> list:
def determine_title_and_text_for_component(
component: dict,
include_html_components: bool = True,
form_lists: list = [],
form_lists: list = None,
is_child: bool = False,
) -> Tuple[str, list]:
"""Determines the title and text to display for an individual component.
Expand All @@ -266,6 +266,8 @@ def determine_title_and_text_for_component(
Returns:
Tuple[str, list]: First item is the title, second is the text to display
"""
if form_lists is None:
form_lists = []
title: str = component["title"] if "title" in component else None
text = []
# skip details, eg about-your-org-cyp GNpQfE
Expand Down Expand Up @@ -320,9 +322,9 @@ def determine_title_and_text_for_component(
def build_components_from_page(
full_page_json: dict,
include_html_components: bool = True,
form_lists: list = [],
form_conditions: list = [],
index_of_printed_headers: dict = {},
form_lists: list = None,
form_conditions: list = None,
index_of_printed_headers: dict = None,
lang: str = "en",
) -> list:
"""Builds a list of the components to display from this page, including their title and text, and
Expand All @@ -349,6 +351,12 @@ def build_components_from_page(
```
"""
# Find out which components in this page determine, through conditions, where we go next
if index_of_printed_headers is None:
index_of_printed_headers = {}
if form_conditions is None:
form_conditions = []
if form_lists is None:
form_lists = []
components_with_conditions = []
for condition in form_conditions:
components_with_conditions.extend([value["field"]["name"] for value in condition["value"]["conditions"]])
Expand Down
4 changes: 3 additions & 1 deletion app/all_questions/read_forms.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
def determine_display_value_for_condition(
condition_value: str,
list_name: str = None,
form_lists: list[dict] = [],
form_lists: list[dict] = None,
lang: str = "en",
) -> str:
"""Determines the display value for the given condition string - either translating true/false into
Expand All @@ -17,6 +17,8 @@ def determine_display_value_for_condition(
Returns:
str: The display value
"""
if form_lists is None:
form_lists = []
if condition_value.casefold() == "true":
return "Yes" if lang == "en" else "Ydy"
elif condition_value.casefold() == "false":
Expand Down
1 change: 0 additions & 1 deletion app/blueprints/self_serve/data/not_a_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,6 @@
"component_names": [],
"show_in_builder": False,
"controller": "./pages/summary.js",
"show_in_builder": False,
},
{
"id": "alternative-organisation-name",
Expand Down
2 changes: 1 addition & 1 deletion app/export_config/generate_assessment_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def generate_assessment_config_for_round(fund_config, round_config, base_output_

unscored = []
sections = db.session.query(Section).filter(Section.round_id == round_id).order_by(Section.index).all()
for i, section in enumerate(sections, start=1):
for _i, section in enumerate(sections, start=1):
criteria = {
"id": human_to_kebab_case(section.name_in_apply_json["en"]),
"name": section.name_in_apply_json["en"],
Expand Down
4 changes: 3 additions & 1 deletion tasks/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,9 @@ def add_default_page_paths(db, default_next_page_config):
db.session.commit()


def insert_test_data(db, test_data={}):
def insert_test_data(db, test_data=None):
if test_data is None:
test_data = {}
db.session.bulk_save_objects(test_data.get("organisations", []))
db.session.commit()
db.session.bulk_save_objects(test_data.get("funds", []))
Expand Down
6 changes: 3 additions & 3 deletions tests/test_generate_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,9 @@ def test_build_page(input_page):
),
],
)
def test_build_conditions(
input_component, exp_results, ids=["single condition", "2 conditions", "single condition with coordinator"]
):
def test_build_conditions(input_component, exp_results, ids=None):
if ids is None:
ids = ["single condition", "2 conditions", "single condition with coordinator"]
results = build_conditions(input_component)
assert results == exp_results

Expand Down

0 comments on commit 6e361cb

Please sign in to comment.