Skip to content

Refactor: simplify manual index checks in find_service_and_method_in_event_name #10564

Description

@Adityaj0

Summary

`awscli/utils.py` `find_service_and_method_in_event_name` (lines ~119-133) manually checks `len(split_event) > 0` / `len(split_event) > 1` to safely index into a list that could have 0, 1, or 2 elements.

Proposed change

Pad the split list to length 2 and unpack directly:
```python
service_name, operation_name = (split_event + [None, None])[:2]
```
Same behavior, no explicit length checks needed. 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