Skip to content
This repository was archived by the owner on Dec 10, 2024. It is now read-only.

Commit

Permalink
Manually fix/ignore ruff linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelhwilliams committed Dec 8, 2024
1 parent 2ad0731 commit 7324435
Show file tree
Hide file tree
Showing 19 changed files with 151 additions and 88 deletions.
2 changes: 1 addition & 1 deletion app/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,4 @@ def compile_static_assets(assets, flask_app):
f" ({flask_app.static_folder}). Please check the static folder"
" exists and expected static files exist at the relative paths,"
f" defined here in the contents of the bundle object -> {e}."
)
) from e
6 changes: 3 additions & 3 deletions app/blueprints/assessments/models/applicants_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ def _convert_to_month_year(input_date):
return str(date_object.strftime("%B %Y"))


def _ui_component_from_factory(item: dict, application_id: str):
def _ui_component_from_factory(item: dict, application_id: str): # noqa: C901
"""
:param item: dict
A dictionary representing the UI component to create. It must contain the following keys:
Expand Down Expand Up @@ -439,14 +439,14 @@ def _get_item_by_presentation_type_index(response: list[dict], presentation_type
for idx, item in enumerate((item for item in response if item["presentation_type"] == presentation_type))
if idx == index
)
except StopIteration:
except StopIteration as e:
raise ValueError(
"Could not find item with presentation_type:"
f" {presentation_type} at index: {index}\nThis probably means"
" there is an uneven number of 'heading', 'description' and"
" 'amount' items\nThere should be an equal number of each of"
" these items"
)
) from e


def _convert_checkbox_items(
Expand Down
2 changes: 1 addition & 1 deletion app/blueprints/assessments/models/round_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def _populate_live_round_stats(round_id_to_summary_map, live_rounds, fund) -> di
return round_id_to_summary_map


def create_round_summaries(fund: Fund, filters: LandingFilters) -> list[RoundSummary]:
def create_round_summaries(fund: Fund, filters: LandingFilters) -> list[RoundSummary]: # noqa: C901
"""Get all the round stats in a fund."""
access_controller = AssessmentAccessController(fund.short_name)

Expand Down
19 changes: 12 additions & 7 deletions app/blueprints/assessments/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,8 @@ def _get_fund_dashboard_data(fund: Fund, round: Round, request):
if users_not_mapped:
current_app.logger.warning(
"The following users were assigned applications but could not be"
f"found in the account store: {users_not_mapped}"
"found in the account store: {users_not_mapped}",
extra=dict(users_not_mapped=users_not_mapped),
)

tags_in_application_map, tag_option_groups = get_tag_map_and_tag_options(
Expand Down Expand Up @@ -803,7 +804,7 @@ def assessor_comments(fund_short_name: str, round_short_name: str):
)
@check_access_fund_short_name_round_sn
@check_access_fund_short_name_round_sn(roles_required=[Config.LEAD_ASSESSOR])
def assignment_overview(fund_short_name: str, round_short_name: str):
def assignment_overview(fund_short_name: str, round_short_name: str): # noqa: C901
# Options to navigate back in the flow to change selections
if "change_users" in request.form:
return redirect(
Expand Down Expand Up @@ -1010,7 +1011,8 @@ def assignment_overview(fund_short_name: str, round_short_name: str):
if future.result() is None:
user_id, application_id = future_assignments[future].split(",")
current_app.logger.error(
f"Could not create assignment for user {user_id} and application {application_id}"
"Could not create assignment for user {user_id} and application {application_id}",
extra=dict(user_id=user_id, application_id=application_id),
)

return redirect(
Expand Down Expand Up @@ -1136,14 +1138,14 @@ def display_sub_criteria(
"""
Page showing sub criteria and themes for an application
"""
current_app.logger.info(f"Processing GET to {request.path}.")
current_app.logger.info("Processing GET to {request_path}.", extra=dict(request_path=request.path))
sub_criteria = get_sub_criteria(application_id, sub_criteria_id)
theme_id = request.args.get("theme_id", sub_criteria.themes[0].id)
comment_form = CommentsForm()
try:
current_theme: Theme = next(iter(t for t in sub_criteria.themes if t.id == theme_id))
except StopIteration:
current_app.logger.warning("Unknown theme ID requested: " + theme_id)
current_app.logger.warning("Unknown theme ID requested: {theme_id}", extra=dict(theme_id=theme_id))
abort(404)
add_comment_argument = request.args.get("add_comment") == "1"
if add_comment_argument and comment_form.validate_on_submit():
Expand Down Expand Up @@ -1257,7 +1259,9 @@ def display_sub_criteria(
@assessment_bp.route("/application/<application_id>/export", methods=["GET"])
@check_access_application_id(roles_required=[Config.LEAD_ASSESSOR])
def generate_doc_list_for_download(application_id):
current_app.logger.info(f"Generating docs for application id {application_id}")
current_app.logger.info(
"Generating docs for application id {application_id}", extra=dict(application_id=application_id)
)
state = get_state_for_tasklist_banner(application_id)
short_id = state.short_id[-6:]
flags_list = get_flags(application_id)
Expand Down Expand Up @@ -1300,7 +1304,8 @@ def generate_doc_list_for_download(application_id):
@check_access_application_id(roles_required=[Config.LEAD_ASSESSOR])
def download_application_answers(application_id: str, short_id: str, file_type: str):
current_app.logger.info(
f"Generating application Q+A download for application {application_id} in {file_type} format"
"Generating application Q+A download for application {application_id} in {file_type} format",
extra=dict(application_id=application_id, file_type=file_type),
)
application_json = get_application_json(application_id)
application_json_blob = application_json["jsonb_blob"]
Expand Down
5 changes: 4 additions & 1 deletion app/blueprints/assessments/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,7 @@ def update_ar_status_to_qa_completed(application_id, user_id):
current_app.logger.info("The application status has been updated to QA_COMPLETE")
return response
else:
current_app.logger.error(f"Could not create qa_complete record for application {application_id}")
current_app.logger.error(
"Could not create qa_complete record for application {application_id}",
extra=dict(application_id=application_id),
)
4 changes: 3 additions & 1 deletion app/blueprints/scoring/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ def get_scoring_class(round_id):
}
scoring_form_class = class_mapping[scoring_system]
except KeyError:
current_app.logger.error(f"Scoring system '{scoring_system}' not found.")
current_app.logger.error(
"Scoring system '{scoring_system}' not found.", extra=dict(scoring_system=scoring_system)
)
abort(
500,
description=f"Scoring system '{scoring_system}' for round {round_id} has not been configured.",
Expand Down
2 changes: 1 addition & 1 deletion app/blueprints/scoring/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def score(
is_rescore = rescore_form.validate_on_submit()
if not is_rescore and request.method == "POST":
if score_form.validate_on_submit():
current_app.logger.info(f"Processing POST to {request.path}.")
current_app.logger.info("Processing POST to {request_path}.", extra=dict(rqeuest_path=request.path))
score = int(score_form.score.data)
user_id = g.account_id
justification = score_form.justification.data
Expand Down
6 changes: 4 additions & 2 deletions app/blueprints/services/aws.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ def get_file_for_download_from_aws(file_name: str, application_id: str):
prefixed_file_name = application_id + "/" + file_name

try:
current_app.logger.info(f"Retrieving file {prefixed_file_name} from AWS")
current_app.logger.info(
"Retrieving file {prefixed_file_name} from AWS", extra=dict(prefixed_file_name=prefixed_file_name)
)
obj = _S3_CLIENT.get_object(Bucket=Config.AWS_BUCKET_NAME, Key=prefixed_file_name)

mimetype = obj["ResponseMetadata"]["HTTPHeaders"]["content-type"]
Expand All @@ -40,7 +42,7 @@ def get_file_for_download_from_aws(file_name: str, application_id: str):
return data, mimetype
except ClientError as e:
current_app.logger.error(e)
raise Exception(e)
raise Exception(e) from e


def list_files_in_folder(prefix):
Expand Down
Loading

0 comments on commit 7324435

Please sign in to comment.