Refactor: simplify manual index checks in find_service_and_method_in_event_name
- Dominant language
- Python
- Stars
- 17.3k
- Forks
- 4.6k
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 13
Description
## 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.
Contributor guide
Research direction
Start in awscli/utils.py at find_service_and_method_in_event_name, around lines 119-133, and inspect how split_event is handled for zero, one, and two elements. Simplify the checks without changing behavior, then verify that all three input shapes still produce the expected service and operation values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Refactor
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 88/100