Skip to content

Refactor: simplify _construct_result in emr createdefaultroles, avoid shadowing builtin list #10572

Description

@Adityaj0

Summary

`awscli/customizations/emr/createdefaultroles.py` `_construct_result` (lines ~208-224) builds its result via a helper, `_construct_role_and_role_policy_structure`, that takes a mutable list parameter literally named `list` (shadowing the builtin) and mutates it in place across three repetitive calls just to conditionally append a dict.

Proposed change

Replace the mutating helper with a list comprehension/filter over the three `(response, policy)` pairs:
```python
return [
{'Role': response['Role'], 'RolePolicy': policy}
for response, policy in responses_and_policies
if response is not None and response['Role'] is not None
]
```
This removes the builtin-shadowing parameter name and the mutating helper entirely. Pure refactor, no behavior change.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triageThis issue or PR still needs to be triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions