Skip to content

Commit d9962cd

Browse files
committed
Flake 8 Fixes
1 parent 4e5afe1 commit d9962cd

File tree

1 file changed

+16
-17
lines changed
  • aws_sra_examples/solutions/patch_mgmt/patch_mgmt_org/lambda/src

1 file changed

+16
-17
lines changed

aws_sra_examples/solutions/patch_mgmt/patch_mgmt_org/lambda/src/app.py

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -147,14 +147,14 @@ def create_maintenance_window(params: dict, account_id: str, regions: list) -> d
147147
return {"window1_ids": window1_ids, "window2_ids": window2_ids, "window3_ids": window3_ids}
148148

149149

150-
def define_maintenance_window_targets(params: dict, window1_id_response: list, window2_id_response: list, window3_id_response: list, account_id: str) -> dict:
150+
def define_mw_targets(params: dict, window1_id_response: list, window2_id_response: list, window3_id_response: list, account_id: str) -> dict[str,list]
151151
"""Define Maintenance Window Targets.
152152
153153
Args:
154154
params (dict): Cloudformation Params
155-
window1_id_response (dict): Previous Window 1 IDs for the Targets
156-
window2_id_response (dict): Previous Window 2 IDs for the Targets
157-
window3_id_response (dict): Previous Window 3 IDs for the Targets
155+
window1_id_response (list): Previous Window 1 IDs for the Targets
156+
window2_id_response (list): Previous Window 2 IDs for the Targets
157+
window3_id_response (list): Previous Window 3 IDs for the Targets
158158
account_id (str): Account ID for the targets to live in
159159
160160
Returns:
@@ -177,7 +177,7 @@ def define_maintenance_window_targets(params: dict, window1_id_response: list, w
177177
target_description = params.get("TARGET1_DESCRIPTION", "")
178178
target_key_value_1 = params.get("TARGET1_VALUE_1", "")
179179
target_key_value_2 = params.get("TARGET1_VALUE_2", "")
180-
print("About to create window " + str(target_name))
180+
LOGGER.info("About to create window " + str(target_name))
181181
maintenance_window_targets = ssmclient.register_target_with_maintenance_window(
182182
Name=target_name,
183183
Description=target_description,
@@ -257,13 +257,8 @@ def define_maintenance_window_targets(params: dict, window1_id_response: list, w
257257
return {"window1_targets": window1_targets, "window2_targets": window2_targets, "window3_targets": window3_targets}
258258

259259

260-
def define_maintenance_window_tasks(
261-
params: dict,
262-
window_id_response: dict,
263-
window_target_response: dict,
264-
account_id: str,
265-
) -> dict:
266-
"""Define maintenance window targets.
260+
def def_mw_tasks( params: dict, window_id_response: dict, window_target_response: dict, account_id: str) -> dict: # noqa: CFQ001
261+
"""Define maintenance window tasks.
267262
268263
Args:
269264
params (dict): Parameters CFN
@@ -293,7 +288,6 @@ def define_maintenance_window_tasks(
293288
task_operation = params.get("TASK1_OPERATION", "Scan")
294289
task_rebootoption = params.get("TASK1_REBOOTOPTION", "NoReboot")
295290

296-
297291
for response2 in window_target_response['window1_targets']:
298292
LOGGER.info(response2)
299293
if (
@@ -468,7 +462,7 @@ def parameter_pattern_validator(parameter_name: str, parameter_value: str, patte
468462

469463
def get_validated_parameters(
470464
event: CloudFormationCustomResourceEvent,
471-
) -> dict: # noqa: CCR001 (cognitive complexity)
465+
) -> dict: # noqa: CCR001 (cognitive complexity), CFQ001
472466
"""Validate AWS CloudFormation parameters.
473467
474468
Args:
@@ -703,9 +697,14 @@ def process_create_update_event(params: dict, regions: list) -> Dict:
703697
all_window_ids.append(window_ids_raw["window1_ids"])
704698
all_window_ids.append(window_ids_raw["window2_ids"])
705699
all_window_ids.append(window_ids_raw["window3_ids"])
706-
window_target_response = define_maintenance_window_targets(params, window_ids_raw["window1_ids"],window_ids_raw["window2_ids"],window_ids_raw["window3_ids"], account_id)
700+
window_target_response = define_mw_targets(
701+
params,
702+
window_ids_raw["window1_ids"],
703+
window_ids_raw["window2_ids"],
704+
window_ids_raw["window3_ids"],
705+
account_id)
707706
all_window_targets.append(window_target_response)
708-
all_window_tasks.append(define_maintenance_window_tasks(params, window_ids_raw, window_target_response, account_id))
707+
all_window_tasks.append(def_mw_tasks(params, window_ids_raw, window_target_response, account_id))
709708
return {"window_ids": all_window_ids, "window_targets": all_window_targets, "window_tasks": all_window_tasks}
710709

711710

@@ -722,7 +721,7 @@ def process_cloudformation_event(event: CloudFormationCustomResourceEvent, conte
722721
Returns:
723722
AWS CloudFormation physical resource id
724723
"""
725-
request_type = event["RequestType"]
724+
request_type = event["RequestType"]
726725
LOGGER.info(f"{request_type} Event")
727726
LOGGER.debug(f"Lambda Context: {context}")
728727

0 commit comments

Comments
 (0)