aws / aws/aws-cli

Refactor: simplify manual index checks in find_service_and_method_in_event_name

Open Beginner friendly
#10,564 0 comments 0 reactions 0 assignees View on GitHub
needs-triage
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.